1 2failures=0 3 4check() { 5 testcase=$1 6 expect=$2 7 eval "set -- $testcase" 8 actual="$*" 9 if [ "$actual" != "$expect" ]; then 10 failures=$((failures+1)) 11 printf '%s\n' "For $testcase, expected $expect actual $actual" 12 fi 13} 14 15set -e 16T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) 17trap 'rm -rf $T' 0 18cd -P $T 19 20mkdir !!a 21touch !!a/fff 22 23chmod u-r . 24check '!!a/ff*' '!!a/fff' 25chmod u+r . 26 27exit $((failures != 0)) 28