ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
540 B

#!/bin/sh
# POSIX compliant regular expressions
# Matches any string that contains a null byte or begins or ends with a /
REGEX1='(^/|/$|\\0)'
# Matches any string longer than 255 characters (for a single filename)
REGEX2='^.{256,}$'
# Matches any string longer than 4096 characters (for a full path)
REGEX3='^.{4097,}$'
if echo "$1" | grep -Eq "$REGEX1" || echo "$1" | grep -Eq "$REGEX2" || echo "$1" | grep -Eq "$REGEX3"; then
# If any regex matches, this is an invalid path
exit 1
else
# Otherwise, it's valid
exit 0
fi