diff options
author | jmmv <jmmv@FreeBSD.org> | 2014-03-09 17:04:31 +0000 |
---|---|---|
committer | jmmv <jmmv@FreeBSD.org> | 2014-03-09 17:04:31 +0000 |
commit | 80efbcbbcda6a5c59a21cb9628b2fd0573697dfe (patch) | |
tree | 2eed051c6d4bc448ea3f0f646cd5dbe45f87974c /tools/regression/bin/sh/expansion | |
parent | f3010cfb7d9dbb4553d0cfa508ec09190a32fc7a (diff) | |
download | FreeBSD-src-80efbcbbcda6a5c59a21cb9628b2fd0573697dfe.zip FreeBSD-src-80efbcbbcda6a5c59a21cb9628b2fd0573697dfe.tar.gz |
Sync sh(1) in stable/10 to head.
This is a MFC of all the commits listed below.
My original goal of this change was to only merge the move of the tests
from tools/regression/bin/ into the new layout (which include tests for
sh(1) and other tools as well). However, doing so is tricky due to the
ongoing work in sh(1) and, especially, the many changes to its tests
since stable/10 was first branched.
Merging everything is the simplest way to achieve this goal and, as a
bonus point, we get various fixes and miscellaneous improvements into
the branch.
Per jilles' suggestion, I'm avoiding the merge of a couple of changes
(r256850 and r257506) that required depending kernel changes. I'm also
avoiding very recent changes that have not had a long enough time to be
validated in current.
This is "make tinderbox" clean.
r256735 sh: Remove one syscall when waiting for a foreground job.
r257399 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'.
r257504 sh: Reorder union node to reduce its size on 64-bit platforms.
r257920 sh: Add a test case for would-be assignments that are not due to quoting.
r257929 sh: Properly quote alias output from command -v.
r258489 sh: Add tests for the </dev/null implicit in a background command.
r258533 sh: Add more tests for the </dev/null implicit in a background command.
r258535 sh: Make <&0 disable the </dev/null implicit in a background command.
r258776 sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro.
r259047 sh: Split set -x output into a separate function.
r259210 Migrate tools/regression/bin/ tests to the new layout.
r259844 sh: Remove an unused variable.
r259846 sh: Initialize OPTIND=1 even if it came from the environment.
r259874 sh: Simplify code related to PPID variable.
r259946 sh: Don't check input for non-whitespace if history is disabled.
r260246 sh(1): Discourage use of -e.
r260506 Run the sh(1) and test(1) tests as unprivileged.
r260586 Mark the bin/pax tests as requiring perl.
r260634 Use TAP_TESTS_PERL to register the legacy_test in bin/pax.
r260635 Replace hand-crafted Kyuafiles with automatic generation.
r260654 sh: Remove SIGWINCH handler and just check for resize before every read.
r261121 sh: Add test for nested alias.
r261125 sh: Solve the alias recursion problem in a less hackish way.
r261141 sh: Do not depend on parse/execute split in new alias test.
r261160 sh: Add tests for alias names after another alias.
r261192 sh: Allow aliases to force alias substitution on the following word.
r262533 sh: Make expari() static.
r262565 sh: Do not corrupt internal representation if LINENO inner expansion fails.
r262697 sh: Simplify expari().
Reviewed by: jilles
Diffstat (limited to 'tools/regression/bin/sh/expansion')
77 files changed, 0 insertions, 1992 deletions
diff --git a/tools/regression/bin/sh/expansion/arith1.0 b/tools/regression/bin/sh/expansion/arith1.0 deleted file mode 100644 index 118ba22..0000000 --- a/tools/regression/bin/sh/expansion/arith1.0 +++ /dev/null @@ -1,30 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -check "0&&0" 0 -check "1&&0" 0 -check "0&&1" 0 -check "1&&1" 1 -check "2&&2" 1 -check "1&&2" 1 -check "1<<40&&1<<40" 1 -check "1<<40&&4" 1 - -check "0||0" 0 -check "1||0" 1 -check "0||1" 1 -check "1||1" 1 -check "2||2" 1 -check "1||2" 1 -check "1<<40||1<<40" 1 -check "1<<40||4" 1 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith10.0 b/tools/regression/bin/sh/expansion/arith10.0 deleted file mode 100644 index 1aaf619..0000000 --- a/tools/regression/bin/sh/expansion/arith10.0 +++ /dev/null @@ -1,35 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -readonly ro=4 -rw=1 -check "0 && 0 / 0" 0 -check "1 || 0 / 0" 1 -check "0 && (ro = 2)" 0 -check "ro" 4 -check "1 || (ro = -1)" 1 -check "ro" 4 -check "0 && (rw += 1)" 0 -check "rw" 1 -check "1 || (rw += 1)" 1 -check "rw" 1 -check "0 ? 44 / 0 : 51" 51 -check "0 ? ro = 3 : 52" 52 -check "ro" 4 -check "0 ? rw += 1 : 52" 52 -check "rw" 1 -check "1 ? 68 : 30 / 0" 68 -check "2 ? 1 : (ro += 2)" 1 -check "ro" 4 -check "4 ? 1 : (rw += 1)" 1 -check "rw" 1 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith11.0 b/tools/regression/bin/sh/expansion/arith11.0 deleted file mode 100644 index 6bc7369..0000000 --- a/tools/regression/bin/sh/expansion/arith11.0 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ -# Try to divide the smallest integer by -1. -# On amd64 this causes SIGFPE, so make sure the shell checks. - -# Calculate the minimum possible value, assuming two's complement and -# a certain interpretation of overflow when shifting left. -minint=1 -while [ $((minint <<= 1)) -gt 0 ]; do - : -done -v=$( eval ': $((minint / -1))' 2>&1 >/dev/null) -[ $? -ne 0 ] && [ -n "$v" ] diff --git a/tools/regression/bin/sh/expansion/arith12.0 b/tools/regression/bin/sh/expansion/arith12.0 deleted file mode 100644 index cb7da3b..0000000 --- a/tools/regression/bin/sh/expansion/arith12.0 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -_x=4 y_=5 z_z=6 -[ "$((_x*100+y_*10+z_z))" = 456 ] diff --git a/tools/regression/bin/sh/expansion/arith13.0 b/tools/regression/bin/sh/expansion/arith13.0 deleted file mode 100644 index 207e488..0000000 --- a/tools/regression/bin/sh/expansion/arith13.0 +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ -# Pre-increment and pre-decrement in arithmetic expansion are not in POSIX. -# Require either an error or a correct implementation. - -! (eval 'x=4; [ $((++x)) != 5 ] || [ $x != 5 ]') 2>/dev/null && -! (eval 'x=2; [ $((--x)) != 1 ] || [ $x != 1 ]') 2>/dev/null diff --git a/tools/regression/bin/sh/expansion/arith2.0 b/tools/regression/bin/sh/expansion/arith2.0 deleted file mode 100644 index 95b48a0..0000000 --- a/tools/regression/bin/sh/expansion/arith2.0 +++ /dev/null @@ -1,77 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -# variables -unset v -check "v=2" 2 -check "v" 2 -check "$(($v))" 2 -check "v+=1" 3 -check "v" 3 - -# constants -check "4611686018427387904" 4611686018427387904 -check "0x4000000000000000" 4611686018427387904 -check "0400000000000000000000" 4611686018427387904 -check "0x4Ab0000000000000" 5381801554707742720 -check "010" 8 - -# try out all operators -v=42 -check "!v" 0 -check "!!v" 1 -check "!0" 1 -check "~0" -1 -check "~(-1)" 0 -check "-0" 0 -check "-v" -42 -check "v*v" 1764 -check "v/2" 21 -check "v%10" 2 -check "v+v" 84 -check "v-4" 38 -check "v<<1" 84 -check "v>>1" 21 -check "v<43" 1 -check "v>42" 0 -check "v<=43" 1 -check "v>=43" 0 -check "v==41" 0 -check "v!=42" 0 -check "v&3" 2 -check "v^3" 41 -check "v|3" 43 -check "v>=40&&v<=44" 1 -check "v<40||v>44" 0 -check "(v=42)&&(v+=1)==43" 1 -check "v" 43 -check "(v=42)&&(v-=1)==41" 1 -check "v" 41 -check "(v=42)&&(v*=2)==84" 1 -check "v" 84 -check "(v=42)&&(v/=10)==4" 1 -check "v" 4 -check "(v=42)&&(v%=10)==2" 1 -check "v" 2 -check "(v=42)&&(v<<=1)==84" 1 -check "v" 84 -check "(v=42)&&(v>>=2)==10" 1 -check "v" 10 -check "(v=42)&&(v&=32)==32" 1 -check "v" 32 -check "(v=42)&&(v^=32)==10" 1 -check "v" 10 -check "(v=42)&&(v|=32)==42" 1 -check "v" 42 - -# missing: ternary - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith3.0 b/tools/regression/bin/sh/expansion/arith3.0 deleted file mode 100644 index b69159d..0000000 --- a/tools/regression/bin/sh/expansion/arith3.0 +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -check "1 << 1 + 1 | 1" 5 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith4.0 b/tools/regression/bin/sh/expansion/arith4.0 deleted file mode 100644 index 610dad8..0000000 --- a/tools/regression/bin/sh/expansion/arith4.0 +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -check '20 / 2 / 2' 5 -check '20 - 2 - 2' 16 -unset a b c d -check "a = b = c = d = 1" 1 -check "a == 1 && b == 1 && c == 1 && d == 1" 1 -check "a += b += c += d" 4 -check "a == 4 && b == 3 && c == 2 && d == 1" 1 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith5.0 b/tools/regression/bin/sh/expansion/arith5.0 deleted file mode 100644 index d0f2331..0000000 --- a/tools/regression/bin/sh/expansion/arith5.0 +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ "$2" != "$3" ]; then - failures=$((failures+1)) - echo "For $1, expected $3 actual $2" - fi -} - -unset a -check '$((1+${a:-$((7+2))}))' "$((1+${a:-$((7+2))}))" 10 -check '$((1+${a:=$((2+2))}))' "$((1+${a:=$((2+2))}))" 5 -check '$a' "$a" 4 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/arith6.0 b/tools/regression/bin/sh/expansion/arith6.0 deleted file mode 100644 index fc4589c..0000000 --- a/tools/regression/bin/sh/expansion/arith6.0 +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ - -v1=1\ +\ 1 -v2=D -v3=C123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 -f() { v4="$*"; } - -while [ ${#v2} -lt 1250 ]; do - eval $v2=$((3+${#v2})) $v3=$((4-${#v2})) - eval f $(($v2+ $v1 +$v3)) - if [ $v4 -ne 9 ]; then - echo bad: $v4 -ne 9 at ${#v2} - fi - v2=x$v2 - v3=y$v3 -done diff --git a/tools/regression/bin/sh/expansion/arith7.0 b/tools/regression/bin/sh/expansion/arith7.0 deleted file mode 100644 index 5aada2b..0000000 --- a/tools/regression/bin/sh/expansion/arith7.0 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -v=1+ -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -[ "$(cat <<EOF -$(($v 1)) -EOF -)" = 1025 ] diff --git a/tools/regression/bin/sh/expansion/arith8.0 b/tools/regression/bin/sh/expansion/arith8.0 deleted file mode 100644 index 2d03e50..0000000 --- a/tools/regression/bin/sh/expansion/arith8.0 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -v=$( (eval ': $((08))') 2>&1 >/dev/null) -[ $? -ne 0 ] && [ -n "$v" ] diff --git a/tools/regression/bin/sh/expansion/arith9.0 b/tools/regression/bin/sh/expansion/arith9.0 deleted file mode 100644 index cc8b597..0000000 --- a/tools/regression/bin/sh/expansion/arith9.0 +++ /dev/null @@ -1,20 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if [ $(($1)) != $2 ]; then - failures=$((failures+1)) - echo "For $1, expected $2 actual $(($1))" - fi -} - -check "0 ? 44 : 51" 51 -check "1 ? 68 : 30" 68 -check "2 ? 1 : -5" 1 -check "0 ? 4 : 0 ? 5 : 6" 6 -check "0 ? 4 : 1 ? 5 : 6" 5 -check "1 ? 4 : 0 ? 5 : 6" 4 -check "1 ? 4 : 1 ? 5 : 6" 4 - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/assign1.0 b/tools/regression/bin/sh/expansion/assign1.0 deleted file mode 100644 index d4fa772..0000000 --- a/tools/regression/bin/sh/expansion/assign1.0 +++ /dev/null @@ -1,37 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'v=; set -- ${v=a b} $v' '0|' -testcase 'unset v; set -- ${v=a b} $v' '4|a|b|a|b' -testcase 'v=; set -- ${v:=a b} $v' '4|a|b|a|b' -testcase 'v=; set -- "${v:=a b}" "$v"' '2|a b|a b' -# expect sensible behaviour, although it disagrees with POSIX -testcase 'v=; set -- ${v:=a\ b} $v' '4|a|b|a|b' -testcase 'v=; set -- ${v:=$p} $v' '2|/etc/|/etc/' -testcase 'v=; set -- "${v:=$p}" "$v"' '2|/et[c]/|/et[c]/' -testcase 'v=; set -- "${v:=a\ b}" "$v"' '2|a\ b|a\ b' -testcase 'v=; set -- ${v:="$p"} $v' '2|/etc/|/etc/' -# whether $p is quoted or not shouldn't really matter -testcase 'v=; set -- "${v:="$p"}" "$v"' '2|/et[c]/|/et[c]/' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/cmdsubst1.0 b/tools/regression/bin/sh/expansion/cmdsubst1.0 deleted file mode 100644 index 515c7da..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst1.0 +++ /dev/null @@ -1,48 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if ! eval "[ $* ]"; then - echo "Failed: $*" - : $((failures += 1)) - fi -} - -check '"$(echo abcde)" = "abcde"' -check '"$(echo abcde; :)" = "abcde"' - -check '"$(printf abcde)" = "abcde"' -check '"$(printf abcde; :)" = "abcde"' - -# regular -check '-n "$(umask)"' -check '-n "$(umask; :)"' -check '-n "$(umask 2>&1)"' -check '-n "$(umask 2>&1; :)"' - -# special -check '-n "$(times)"' -check '-n "$(times; :)"' -check '-n "$(times 2>&1)"' -check '-n "$(times 2>&1; :)"' - -# regular -check '".$(umask -@ 2>&1)." = ".umask: Illegal option -@."' -check '".$(umask -@ 2>&1; :)." = ".umask: Illegal option -@."' -check '".$({ umask -@; } 2>&1)." = ".umask: Illegal option -@."' - -# special -check '".$(shift xyz 2>&1)." = ".shift: Illegal number: xyz."' -check '".$(shift xyz 2>&1; :)." = ".shift: Illegal number: xyz."' -check '".$({ shift xyz; } 2>&1)." = ".shift: Illegal number: xyz."' - -v=1 -check '-z "$(v=2 :)"' -check '"$v" = 1' -check '-z "$(v=3)"' -check '"$v" = 1' -check '"$(v=4 eval echo \$v)" = 4' -check '"$v" = 1' - -exit $((failures > 0)) diff --git a/tools/regression/bin/sh/expansion/cmdsubst10.0 b/tools/regression/bin/sh/expansion/cmdsubst10.0 deleted file mode 100644 index 7cf17a3..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst10.0 +++ /dev/null @@ -1,51 +0,0 @@ -# $FreeBSD$ - -a1=$(alias) -: $(alias testalias=abcd) -a2=$(alias) -[ "$a1" = "$a2" ] || echo Error at line $LINENO - -alias testalias2=abcd -a1=$(alias) -: $(unalias testalias2) -a2=$(alias) -[ "$a1" = "$a2" ] || echo Error at line $LINENO - -[ "$(command -V pwd)" = "$(command -V pwd; exit $?)" ] || echo Error at line $LINENO - -v=1 -: $(export v=2) -[ "$v" = 1 ] || echo Error at line $LINENO - -rotest=1 -: $(readonly rotest=2) -[ "$rotest" = 1 ] || echo Error at line $LINENO - -set +u -: $(set -u) -case $- in -*u*) echo Error at line $LINENO ;; -esac -set +u - -set +u -: $(set -o nounset) -case $- in -*u*) echo Error at line $LINENO ;; -esac -set +u - -set +u -: $(command set -u) -case $- in -*u*) echo Error at line $LINENO ;; -esac -set +u - -umask 77 -u1=$(umask) -: $(umask 022) -u2=$(umask) -[ "$u1" = "$u2" ] || echo Error at line $LINENO - -dummy=$(exit 3); [ $? -eq 3 ] || echo Error at line $LINENO diff --git a/tools/regression/bin/sh/expansion/cmdsubst11.0 b/tools/regression/bin/sh/expansion/cmdsubst11.0 deleted file mode 100644 index f1af547..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst11.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -# Not required by POSIX but useful for efficiency. - -[ $$ = $(eval '${SH} -c echo\ \$PPID') ] diff --git a/tools/regression/bin/sh/expansion/cmdsubst12.0 b/tools/regression/bin/sh/expansion/cmdsubst12.0 deleted file mode 100644 index 50394db..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst12.0 +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -f() { - echo x$(printf foo >&2)y -} -[ "$(f 2>&1)" = "fooxy" ] diff --git a/tools/regression/bin/sh/expansion/cmdsubst13.0 b/tools/regression/bin/sh/expansion/cmdsubst13.0 deleted file mode 100644 index 7fdc5b2..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst13.0 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -x=1 y=2 -[ "$( - case $((x+=1)) in - ($((y+=1))) echo bad1 ;; - ($((y-1))) echo $x.$y ;; - ($((y=2))) echo bad2 ;; - (*) echo bad3 ;; - esac -)" = "2.3" ] || echo "Error at $LINENO" -[ "$x.$y" = "1.2" ] || echo "Error at $LINENO" diff --git a/tools/regression/bin/sh/expansion/cmdsubst14.0 b/tools/regression/bin/sh/expansion/cmdsubst14.0 deleted file mode 100644 index bdbbb82..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst14.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -! v=`false - -` diff --git a/tools/regression/bin/sh/expansion/cmdsubst15.0 b/tools/regression/bin/sh/expansion/cmdsubst15.0 deleted file mode 100644 index 31d85d4..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst15.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -! v=`false; - -` diff --git a/tools/regression/bin/sh/expansion/cmdsubst16.0 b/tools/regression/bin/sh/expansion/cmdsubst16.0 deleted file mode 100644 index 71df562..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst16.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -f() { return 3; } -f -[ `echo $?` = 3 ] diff --git a/tools/regression/bin/sh/expansion/cmdsubst17.0 b/tools/regression/bin/sh/expansion/cmdsubst17.0 deleted file mode 100644 index 8c29e83..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst17.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -f() { return 3; } -f -[ `echo $?; :` = 3 ] diff --git a/tools/regression/bin/sh/expansion/cmdsubst2.0 b/tools/regression/bin/sh/expansion/cmdsubst2.0 deleted file mode 100644 index b86776e..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst2.0 +++ /dev/null @@ -1,43 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - if ! eval "[ $* ]"; then - echo "Failed: $*" - : $((failures += 1)) - fi -} - -check '`echo /et[c]/` = "/etc/"' -check '`printf /var/empty%s /et[c]/` = "/var/empty/etc/"' -check '"`echo /et[c]/`" = "/etc/"' -check '`echo "/et[c]/"` = "/etc/"' -check '`printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"' -check '`printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""' -check '"`echo \"/et[c]/\"`" = "/et[c]/"' -check '"`echo "/et[c]/"`" = "/et[c]/"' -check '`echo $$` = $$' -check '"`echo $$`" = $$' -check '`echo \$\$` = $$' -check '"`echo \$\$`" = $$' - -# Command substitutions consisting of a single builtin may be treated -# differently. -check '`:; echo /et[c]/` = "/etc/"' -check '`:; printf /var/empty%s /et[c]/` = "/var/empty/etc/"' -check '"`:; echo /et[c]/`" = "/etc/"' -check '`:; echo "/et[c]/"` = "/etc/"' -check '`:; printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"' -check '`:; printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""' -check '"`:; echo \"/et[c]/\"`" = "/et[c]/"' -check '"`:; echo "/et[c]/"`" = "/et[c]/"' -check '`:; echo $$` = $$' -check '"`:; echo $$`" = $$' -check '`:; echo \$\$` = $$' -check '"`:; echo \$\$`" = $$' - -check '`set -f; echo /et[c]/` = "/etc/"' -check '"`set -f; echo /et[c]/`" = "/et[c]/"' - -exit $((failures > 0)) diff --git a/tools/regression/bin/sh/expansion/cmdsubst3.0 b/tools/regression/bin/sh/expansion/cmdsubst3.0 deleted file mode 100644 index abb6b22..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst3.0 +++ /dev/null @@ -1,23 +0,0 @@ -# $FreeBSD$ - -unset LC_ALL -export LC_CTYPE=en_US.ISO8859-1 - -e= -for i in 0 1 2 3; do - for j in 0 1 2 3 4 5 6 7; do - for k in 0 1 2 3 4 5 6 7; do - case $i$j$k in - 000) continue ;; - esac - e="$e\n\\$i$j$k" - done - done -done -e1=$(printf "$e") -e2="$(printf "$e")" -[ "${#e1}" = 510 ] || echo length bad -[ "$e1" = "$e2" ] || echo e1 != e2 -[ "$e1" = "$(printf "$e")" ] || echo quoted bad -IFS= -[ "$e1" = $(printf "$e") ] || echo unquoted bad diff --git a/tools/regression/bin/sh/expansion/cmdsubst4.0 b/tools/regression/bin/sh/expansion/cmdsubst4.0 deleted file mode 100644 index ee1ce73..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst4.0 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -exec 2>/dev/null -! y=$(: </var/empty/nonexistent) diff --git a/tools/regression/bin/sh/expansion/cmdsubst5.0 b/tools/regression/bin/sh/expansion/cmdsubst5.0 deleted file mode 100644 index afca371..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst5.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -unset v -exec 2>/dev/null -! y=$(: ${v?}) diff --git a/tools/regression/bin/sh/expansion/cmdsubst6.0 b/tools/regression/bin/sh/expansion/cmdsubst6.0 deleted file mode 100644 index 6586f33..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst6.0 +++ /dev/null @@ -1,53 +0,0 @@ -# $FreeBSD$ -# This tests if the cmdsubst optimization is still used if possible. - -failures='' -ok='' - -testcase() { - code="$1" - - unset v - eval "pid=\$(dummy=$code echo \$(\$SH -c echo\ \\\$PPID))" - - if [ "$pid" = "$$" ]; then - ok=x$ok - else - failures=x$failures - echo "Failure for $code" - fi -} - -unset v -w=1 -testcase '$w' -testcase '1${w+1}' -testcase '1${w-1}' -testcase '1${v+1}' -testcase '1${v-1}' -testcase '1${w:+1}' -testcase '1${w:-1}' -testcase '1${v:+1}' -testcase '1${v:-1}' -testcase '${w?}' -testcase '${w:?}' -testcase '${w#x}' -testcase '${w##x}' -testcase '${w%x}' -testcase '${w%%x}' - -testcase '$((w))' -testcase '$(((w+4)*2/3))' -testcase '$((w==1))' -testcase '$((w>=0 && w<=5 && w!=2))' -testcase '$((${#w}))' -testcase '$((${#IFS}))' -testcase '$((${#w}>=1))' -testcase '$(($$))' -testcase '$(($#))' -testcase '$(($?))' - -testcase '$(: $((w=4)))' -testcase '$(: ${v=2})' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/cmdsubst7.0 b/tools/regression/bin/sh/expansion/cmdsubst7.0 deleted file mode 100644 index dbd1aec..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst7.0 +++ /dev/null @@ -1,31 +0,0 @@ -# $FreeBSD$ - -failures='' -ok='' - -testcase() { - code="$1" - - unset v - eval ": \$($code)" - - if [ "${v:+bad}" = "" ]; then - ok=x$ok - else - failures=x$failures - echo "Failure for $code" - fi -} - -testcase ': ${v=0}' -testcase ': ${v:=0}' -testcase ': $((v=1))' -testcase ': $((v+=1))' -w='v=1' -testcase ': $(($w))' -testcase ': $((${$+v=1}))' -testcase ': $((v${$+=1}))' -testcase ': $((v $(echo =) 1))' -testcase ': $(($(echo $w)))' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/cmdsubst8.0 b/tools/regression/bin/sh/expansion/cmdsubst8.0 deleted file mode 100644 index 52adaea..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst8.0 +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ -# Not required by POSIX (although referenced in a non-normative section), -# but possibly useful. - -: hi there & -p=$! -q=$(jobs -l $p) - -# Change tabs to spaces. -set -f -set -- $q -r="$*" - -case $r in -*" $p "*) ;; -*) echo Pid missing; exit 3 ;; -esac diff --git a/tools/regression/bin/sh/expansion/cmdsubst9.0 b/tools/regression/bin/sh/expansion/cmdsubst9.0 deleted file mode 100644 index 0b1f81f..0000000 --- a/tools/regression/bin/sh/expansion/cmdsubst9.0 +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ - -set -e - -cd / -dummy=$(cd /bin) -[ "$(pwd)" = / ] - -v=1 -dummy=$(eval v=2) -[ "$v" = 1 ] diff --git a/tools/regression/bin/sh/expansion/export1.0 b/tools/regression/bin/sh/expansion/export1.0 deleted file mode 100644 index 4ee3ef4..0000000 --- a/tools/regression/bin/sh/expansion/export1.0 +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ - -w='@ vv=6' - -v=0 vv=0 -export \v=$w -[ "$v" = "@" ] || echo "Expected @ got $v" -[ "$vv" = "6" ] || echo "Expected 6 got $vv" - -HOME=/known/value - -export \v=~ -[ "$v" = \~ ] || echo "Expected ~ got $v" diff --git a/tools/regression/bin/sh/expansion/export2.0 b/tools/regression/bin/sh/expansion/export2.0 deleted file mode 100644 index 57f64e7..0000000 --- a/tools/regression/bin/sh/expansion/export2.0 +++ /dev/null @@ -1,24 +0,0 @@ -# $FreeBSD$ - -w='@ @' -check() { - [ "$v" = "$w" ] || echo "Expected $w got $v" -} - -export v=$w -check - -HOME=/known/value -check() { - [ "$v" = ~ ] || echo "Expected $HOME got $v" -} - -export v=~ -check - -check() { - [ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v" -} - -export v=x:~ -check diff --git a/tools/regression/bin/sh/expansion/export3.0 b/tools/regression/bin/sh/expansion/export3.0 deleted file mode 100644 index a1a0e66..0000000 --- a/tools/regression/bin/sh/expansion/export3.0 +++ /dev/null @@ -1,30 +0,0 @@ -# $FreeBSD$ - -w='@ @' -check() { - [ "$v" = "$w" ] || echo "Expected $w got $v" -} - -command export v=$w -check -command command export v=$w -check - -HOME=/known/value -check() { - [ "$v" = ~ ] || echo "Expected $HOME got $v" -} - -command export v=~ -check -command command export v=~ -check - -check() { - [ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v" -} - -command export v=x:~ -check -command command export v=x:~ -check diff --git a/tools/regression/bin/sh/expansion/heredoc1.0 b/tools/regression/bin/sh/expansion/heredoc1.0 deleted file mode 100644 index a67b2da..0000000 --- a/tools/regression/bin/sh/expansion/heredoc1.0 +++ /dev/null @@ -1,25 +0,0 @@ -# $FreeBSD$ - -f() { return $1; } - -[ `f 42; { cat; } <<EOF -$? -EOF -` = 42 ] || echo compound command bad - -[ `f 42; (cat) <<EOF -$? -EOF -` = 42 ] || echo subshell bad - -long=`printf %08192d 0` - -[ `f 42; { cat; } <<EOF -$long.$? -EOF -` = $long.42 ] || echo long compound command bad - -[ `f 42; (cat) <<EOF -$long.$? -EOF -` = $long.42 ] || echo long subshell bad diff --git a/tools/regression/bin/sh/expansion/heredoc2.0 b/tools/regression/bin/sh/expansion/heredoc2.0 deleted file mode 100644 index 2551432..0000000 --- a/tools/regression/bin/sh/expansion/heredoc2.0 +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD$ - -f() { return $1; } - -[ `f 42; cat <<EOF -$? -EOF -` = 42 ] || echo simple command bad - -long=`printf %08192d 0` - -[ `f 42; cat <<EOF -$long.$? -EOF -` = $long.42 ] || echo long simple command bad diff --git a/tools/regression/bin/sh/expansion/ifs1.0 b/tools/regression/bin/sh/expansion/ifs1.0 deleted file mode 100644 index e7f53c7..0000000 --- a/tools/regression/bin/sh/expansion/ifs1.0 +++ /dev/null @@ -1,35 +0,0 @@ -# $FreeBSD$ - -c=: e= s=' ' -failures='' -ok='' - -check_result() { - if [ "x$2" = "x$3" ]; then - ok=x$ok - else - failures=x$failures - echo "For $1, expected $3 actual $2" - fi -} - -IFS=' -' -set -- a '' -set -- "$@" -check_result 'set -- "$@"' "($#)($1)($2)" "(2)(a)()" - -set -- a '' -set -- "$@"$e -check_result 'set -- "$@"$e' "($#)($1)($2)" "(2)(a)()" - -set -- a '' -set -- "$@"$s -check_result 'set -- "$@"$s' "($#)($1)($2)" "(2)(a)()" - -IFS="$c" -set -- a '' -set -- "$@"$c -check_result 'set -- "$@"$c' "($#)($1)($2)" "(2)(a)()" - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/ifs2.0 b/tools/regression/bin/sh/expansion/ifs2.0 deleted file mode 100644 index e91b867..0000000 --- a/tools/regression/bin/sh/expansion/ifs2.0 +++ /dev/null @@ -1,24 +0,0 @@ -# $FreeBSD$ - -failures=0 -i=1 -set -f -while [ "$i" -le 127 ]; do - # A different byte still in the range 1..127. - i2=$((i^2+(i==2))) - # Add a character to work around command substitution's removal of - # final newlines, then remove it again. - c=$(printf \\"$(printf %o@ "$i")") - c=${c%@} - c2=$(printf \\"$(printf %o@ "$i2")") - c2=${c2%@} - IFS=$c - set -- $c2$c$c2$c$c2 - if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] || - [ "$3" != "$c2" ]; then - echo "Bad results for separator $i (word $i2)" >&2 - : $((failures += 1)) - fi - i=$((i+1)) -done -exit $((failures > 0)) diff --git a/tools/regression/bin/sh/expansion/ifs3.0 b/tools/regression/bin/sh/expansion/ifs3.0 deleted file mode 100644 index 0569b57..0000000 --- a/tools/regression/bin/sh/expansion/ifs3.0 +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD$ - -failures=0 -unset LC_ALL -export LC_CTYPE=en_US.ISO8859-1 -i=128 -set -f -while [ "$i" -le 255 ]; do - i2=$((i^2)) - c=$(printf \\"$(printf %o "$i")") - c2=$(printf \\"$(printf %o "$i2")") - IFS=$c - set -- $c2$c$c2$c$c2 - if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] || - [ "$3" != "$c2" ]; then - echo "Bad results for separator $i (word $i2)" >&2 - : $((failures += 1)) - fi - i=$((i+1)) -done -exit $((failures > 0)) diff --git a/tools/regression/bin/sh/expansion/ifs4.0 b/tools/regression/bin/sh/expansion/ifs4.0 deleted file mode 100644 index 5b896a2..0000000 --- a/tools/regression/bin/sh/expansion/ifs4.0 +++ /dev/null @@ -1,39 +0,0 @@ -# $FreeBSD$ - -c=: e= s=' ' -failures='' -ok='' - -check_result() { - if [ "x$2" = "x$3" ]; then - ok=x$ok - else - failures=x$failures - echo "For $1, expected $3 actual $2" - fi -} - -IFS=' -' -set -- a b '' c -set -- $@ -check_result 'set -- $@' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()" - -IFS='' -set -- a b '' c -set -- $@ -check_result 'set -- $@' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()" - -set -- a b '' c -set -- $* -check_result 'set -- $*' "($#)($1)($2)($3)($4)" "(3)(a)(b)(c)()" - -set -- a b '' c -set -- "$@" -check_result 'set -- "$@"' "($#)($1)($2)($3)($4)" "(4)(a)(b)()(c)" - -set -- a b '' c -set -- "$*" -check_result 'set -- "$*"' "($#)($1)($2)($3)($4)" "(1)(abc)()()()" - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/length1.0 b/tools/regression/bin/sh/expansion/length1.0 deleted file mode 100644 index 2aaebf9..0000000 --- a/tools/regression/bin/sh/expansion/length1.0 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -v=abcd -[ "${#v}" = 4 ] || echo '${#v} wrong' -v=$$ -[ "${#$}" = "${#v}" ] || echo '${#$} wrong' -[ "${#!}" = 0 ] || echo '${#!} wrong' -set -- 01 2 3 4 5 6 7 8 9 10 11 12 0013 -[ "${#1}" = 2 ] || echo '${#1} wrong' -[ "${#13}" = 4 ] || echo '${#13} wrong' -v=$0 -[ "${#0}" = "${#v}" ] || echo '${#0} wrong' diff --git a/tools/regression/bin/sh/expansion/length2.0 b/tools/regression/bin/sh/expansion/length2.0 deleted file mode 100644 index d749b51..0000000 --- a/tools/regression/bin/sh/expansion/length2.0 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -v=$- -[ "${#-}" = "${#v}" ] || echo '${#-} wrong' diff --git a/tools/regression/bin/sh/expansion/length3.0 b/tools/regression/bin/sh/expansion/length3.0 deleted file mode 100644 index 2093eed..0000000 --- a/tools/regression/bin/sh/expansion/length3.0 +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD$ - -set -- 1 2 3 4 5 6 7 8 9 10 11 12 13 -[ "$#" = 13 ] || echo '$# wrong' -[ "${#}" = 13 ] || echo '${#} wrong' -[ "${##}" = 2 ] || echo '${##} wrong' -set -- -[ "$#" = 0 ] || echo '$# wrong' -[ "${#}" = 0 ] || echo '${#} wrong' -[ "${##}" = 1 ] || echo '${##} wrong' diff --git a/tools/regression/bin/sh/expansion/length4.0 b/tools/regression/bin/sh/expansion/length4.0 deleted file mode 100644 index 5348be5..0000000 --- a/tools/regression/bin/sh/expansion/length4.0 +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD$ - -# The construct ${#?} is ambiguous in POSIX.1-2008: it could be the length -# of $? or it could be $# giving an error in the (impossible) case that it -# is not set. -# We use the former interpretation; it seems more useful. - -: -[ "${#?}" = 1 ] || echo '${#?} wrong' -(exit 42) -[ "${#?}" = 2 ] || echo '${#?} wrong' diff --git a/tools/regression/bin/sh/expansion/length5.0 b/tools/regression/bin/sh/expansion/length5.0 deleted file mode 100644 index 322ca16..0000000 --- a/tools/regression/bin/sh/expansion/length5.0 +++ /dev/null @@ -1,27 +0,0 @@ -# $FreeBSD$ - -unset LC_ALL -LC_CTYPE=en_US.ISO8859-1 -export LC_CTYPE - -e= -for i in 0 1 2 3; do - for j in 0 1 2 3 4 5 6 7; do - for k in 0 1 2 3 4 5 6 7; do - case $i$j$k in - 000) continue ;; - esac - e="$e\\$i$j$k" - done - done -done -ee=`printf "$e"` -[ ${#ee} = 255 ] || echo bad 1 -[ "${#ee}" = 255 ] || echo bad 2 -[ $((${#ee})) = 255 ] || echo bad 3 -[ "$((${#ee}))" = 255 ] || echo bad 4 -set -- "$ee" -[ ${#1} = 255 ] || echo bad 5 -[ "${#1}" = 255 ] || echo bad 6 -[ $((${#1})) = 255 ] || echo bad 7 -[ "$((${#1}))" = 255 ] || echo bad 8 diff --git a/tools/regression/bin/sh/expansion/length6.0 b/tools/regression/bin/sh/expansion/length6.0 deleted file mode 100644 index 6b78309..0000000 --- a/tools/regression/bin/sh/expansion/length6.0 +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD$ - -x='!@#$%^&*()[]' -[ ${#x} = 12 ] || echo bad 1 -[ "${#x}" = 12 ] || echo bad 2 -IFS=2 -[ ${#x} = 1 ] || echo bad 3 -[ "${#x}" = 12 ] || echo bad 4 diff --git a/tools/regression/bin/sh/expansion/length7.0 b/tools/regression/bin/sh/expansion/length7.0 deleted file mode 100644 index b79b116..0000000 --- a/tools/regression/bin/sh/expansion/length7.0 +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -unset LC_ALL -LC_CTYPE=en_US.UTF-8 -export LC_CTYPE - -# a umlaut -s=$(printf '\303\244') -# euro sign -s=$s$(printf '\342\202\254') -# some sort of 't' outside BMP -s=$s$(printf '\360\235\225\245') -set -- "$s" -[ ${#s} = 3 ] && [ ${#1} = 3 ] diff --git a/tools/regression/bin/sh/expansion/length8.0 b/tools/regression/bin/sh/expansion/length8.0 deleted file mode 100644 index 3cc6c15..0000000 --- a/tools/regression/bin/sh/expansion/length8.0 +++ /dev/null @@ -1,14 +0,0 @@ -# $FreeBSD$ - -unset LC_ALL -LC_CTYPE=en_US.ISO8859-1 -export LC_CTYPE - -# a umlaut -s=$(printf '\303\244') -# euro sign -s=$s$(printf '\342\202\254') -# some sort of 't' outside BMP -s=$s$(printf '\360\235\225\245') -set -- "$s" -[ ${#s} = 9 ] && [ ${#1} = 9 ] diff --git a/tools/regression/bin/sh/expansion/local1.0 b/tools/regression/bin/sh/expansion/local1.0 deleted file mode 100644 index 3477835..0000000 --- a/tools/regression/bin/sh/expansion/local1.0 +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -run_test() { - w='@ @' - check() { - [ "$v" = "$w" ] || echo "Expected $w got $v" - } - - local v=$w - check - - HOME=/known/value - check() { - [ "$v" = ~ ] || echo "Expected $HOME got $v" - } - - local v=~ - check - - check() { - [ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v" - } - - local v=x:~ - check -} - -run_test diff --git a/tools/regression/bin/sh/expansion/local2.0 b/tools/regression/bin/sh/expansion/local2.0 deleted file mode 100644 index 1984290..0000000 --- a/tools/regression/bin/sh/expansion/local2.0 +++ /dev/null @@ -1,34 +0,0 @@ -# $FreeBSD$ - -run_test() { - w='@ @' - check() { - [ "$v" = "$w" ] || echo "Expected $w got $v" - } - - command local v=$w - check - command command local v=$w - check - - HOME=/known/value - check() { - [ "$v" = ~ ] || echo "Expected $HOME got $v" - } - - command local v=~ - check - command command local v=~ - check - - check() { - [ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v" - } - - command local v=x:~ - check - command command local v=x:~ - check -} - -run_test diff --git a/tools/regression/bin/sh/expansion/pathname1.0 b/tools/regression/bin/sh/expansion/pathname1.0 deleted file mode 100644 index 8c6b01c..0000000 --- a/tools/regression/bin/sh/expansion/pathname1.0 +++ /dev/null @@ -1,61 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - testcase=$1 - expect=$2 - eval "set -- $testcase" - actual="$*" - if [ "$actual" != "$expect" ]; then - failures=$((failures+1)) - printf '%s\n' "For $testcase, expected $expect actual $actual" - fi -} - -set -e -T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) -trap 'rm -rf $T' 0 -cd -P $T - -mkdir testdir testdir2 'testdir/*' 'testdir/?' testdir/a testdir/b testdir2/b -mkdir testdir2/.c -touch testf 'testdir/*/1' 'testdir/?/1' testdir/a/1 testdir/b/1 testdir2/b/.a - -check '' '' -check 'testdir/b' 'testdir/b' -check 'testdir/c' 'testdir/c' -check '\*' '*' -check '\?' '?' -check '*' 'testdir testdir2 testf' -check '*""' 'testdir testdir2 testf' -check '""*' 'testdir testdir2 testf' -check '*/' 'testdir/ testdir2/' -check 'testdir*/a' 'testdir/a' -check 'testdir*/b' 'testdir/b testdir2/b' -check '*/.c' 'testdir2/.c' -check 'testdir2/*' 'testdir2/b' -check 'testdir2/b/*' 'testdir2/b/*' -check 'testdir/*' 'testdir/* testdir/? testdir/a testdir/b' -check 'testdir/*/1' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' -check '"testdir/"*/1' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' -check 'testdir/\*/*' 'testdir/*/1' -check 'testdir/\?/*' 'testdir/?/1' -check 'testdir/"?"/*' 'testdir/?/1' -check '"testdir"/"?"/*' 'testdir/?/1' -check '"testdir"/"?"*/*' 'testdir/?/1' -check '"testdir"/*"?"/*' 'testdir/?/1' -check '"testdir/?"*/*' 'testdir/?/1' -check 'testdir/\*/' 'testdir/*/' -check 'testdir/\?/' 'testdir/?/' -check 'testdir/"?"/' 'testdir/?/' -check '"testdir"/"?"/' 'testdir/?/' -check '"testdir"/"?"*/' 'testdir/?/' -check '"testdir"/*"?"/' 'testdir/?/' -check '"testdir/?"*/' 'testdir/?/' -check 'testdir/[*]/' 'testdir/*/' -check 'testdir/[?]/' 'testdir/?/' -check 'testdir/[*?]/' 'testdir/*/ testdir/?/' -check '[tz]estdir/[*]/' 'testdir/*/' - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/pathname2.0 b/tools/regression/bin/sh/expansion/pathname2.0 deleted file mode 100644 index 8a884ff..0000000 --- a/tools/regression/bin/sh/expansion/pathname2.0 +++ /dev/null @@ -1,31 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - testcase=$1 - expect=$2 - eval "set -- $testcase" - actual="$*" - if [ "$actual" != "$expect" ]; then - failures=$((failures+1)) - printf '%s\n' "For $testcase, expected $expect actual $actual" - fi -} - -set -e -T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) -trap 'rm -rf $T' 0 -cd -P $T - -mkdir testdir testdir2 'testdir/*' 'testdir/?' testdir/a testdir/b testdir2/b -mkdir testdir2/.c -touch testf 'testdir/*/1' 'testdir/?/1' testdir/a/1 testdir/b/1 testdir2/b/.a - -check '*\/' 'testdir/ testdir2/' -check '"testdir/"*"/1"' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' -check '"testdir/"*"/"*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' -check '"testdir/"*\/*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' -check '"testdir"*"/"*"/"*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1' - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/pathname3.0 b/tools/regression/bin/sh/expansion/pathname3.0 deleted file mode 100644 index d1672e0..0000000 --- a/tools/regression/bin/sh/expansion/pathname3.0 +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD$ - -v=12345678 -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -v=$v$v$v$v -# 8192 bytes -v=${v##???} -[ /*/$v = "/*/$v" ] || exit 1 - -s=//// -s=$s$s$s$s -s=$s$s$s$s -s=$s$s$s$s -s=$s$s$s$s -# 1024 bytes -s=${s##??????????} -[ /var/empt[y]/$s/$v = "/var/empt[y]/$s/$v" ] || exit 2 -while [ ${#s} -lt 1034 ]; do - set -- /.${s}et[c] - [ ${#s} -gt 1018 ] || [ "$1" = /.${s}etc ] || exit 3 - set -- /.${s}et[c]/ - [ ${#s} -gt 1017 ] || [ "$1" = /.${s}etc/ ] || exit 4 - set -- /.${s}et[c]/. - [ ${#s} -gt 1016 ] || [ "$1" = /.${s}etc/. ] || exit 5 - s=$s/ -done diff --git a/tools/regression/bin/sh/expansion/pathname4.0 b/tools/regression/bin/sh/expansion/pathname4.0 deleted file mode 100644 index 18269c4..0000000 --- a/tools/regression/bin/sh/expansion/pathname4.0 +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -failures=0 - -check() { - testcase=$1 - expect=$2 - eval "set -- $testcase" - actual="$*" - if [ "$actual" != "$expect" ]; then - failures=$((failures+1)) - printf '%s\n' "For $testcase, expected $expect actual $actual" - fi -} - -set -e -T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) -trap 'rm -rf $T' 0 -cd -P $T - -mkdir !!a -touch !!a/fff - -chmod u-r . -check '!!a/ff*' '!!a/fff' -chmod u+r . - -exit $((failures != 0)) diff --git a/tools/regression/bin/sh/expansion/plus-minus1.0 b/tools/regression/bin/sh/expansion/plus-minus1.0 deleted file mode 100644 index 9a6a53a..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus1.0 +++ /dev/null @@ -1,76 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- a b' '2|a|b' -testcase 'set --' '0|' -testcase 'set -- ${e}' '0|' -testcase 'set -- "${e}"' '1|' - -testcase 'set -- $p' '1|/etc/' -testcase 'set -- "$p"' '1|/et[c]/' -testcase 'set -- ${s+$p}' '1|/etc/' -testcase 'set -- "${s+$p}"' '1|/et[c]/' -testcase 'set -- ${s+"$p"}' '1|/et[c]/' -# Dquotes in dquotes is undefined for Bourne shell operators -#testcase 'set -- "${s+"$p"}"' '1|/et[c]/' -testcase 'set -- ${e:-$p}' '1|/etc/' -testcase 'set -- "${e:-$p}"' '1|/et[c]/' -testcase 'set -- ${e:-"$p"}' '1|/et[c]/' -# Dquotes in dquotes is undefined for Bourne shell operators -#testcase 'set -- "${e:-"$p"}"' '1|/et[c]/' -testcase 'set -- ${e:+"$e"}' '0|' -testcase 'set -- ${e:+$w"$e"}' '0|' -testcase 'set -- ${w:+"$w"}' '1|a b c' -testcase 'set -- ${w:+$w"$w"}' '3|a|b|ca b c' - -testcase 'set -- "${s+a b}"' '1|a b' -testcase 'set -- "${e:-a b}"' '1|a b' -testcase 'set -- ${e:-\}}' '1|}' -testcase 'set -- ${e:+{}}' '1|}' -testcase 'set -- "${e:+{}}"' '1|}' - -testcase 'set -- ${e+x}${e+x}' '1|xx' -testcase 'set -- "${e+x}"${e+x}' '1|xx' -testcase 'set -- ${e+x}"${e+x}"' '1|xx' -testcase 'set -- "${e+x}${e+x}"' '1|xx' -testcase 'set -- "${e+x}""${e+x}"' '1|xx' - -testcase 'set -- ${e:-${e:-$p}}' '1|/etc/' -testcase 'set -- "${e:-${e:-$p}}"' '1|/et[c]/' -testcase 'set -- ${e:-"${e:-$p}"}' '1|/et[c]/' -testcase 'set -- ${e:-${e:-"$p"}}' '1|/et[c]/' -testcase 'set -- ${e:-${e:-${e:-$w}}}' '3|a|b|c' -testcase 'set -- ${e:-${e:-${e:-"$w"}}}' '1|a b c' -testcase 'set -- ${e:-${e:-"${e:-$w}"}}' '1|a b c' -testcase 'set -- ${e:-"${e:-${e:-$w}}"}' '1|a b c' -testcase 'set -- "${e:-${e:-${e:-$w}}}"' '1|a b c' - -testcase 'shift $#; set -- ${1+"$@"}' '0|' -testcase 'set -- ""; set -- ${1+"$@"}' '1|' -testcase 'set -- "" a; set -- ${1+"$@"}' '2||a' -testcase 'set -- a ""; set -- ${1+"$@"}' '2|a|' -testcase 'set -- a b; set -- ${1+"$@"}' '2|a|b' -testcase 'set -- a\ b; set -- ${1+"$@"}' '1|a b' -testcase 'set -- " " ""; set -- ${1+"$@"}' '2| |' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/plus-minus2.0 b/tools/regression/bin/sh/expansion/plus-minus2.0 deleted file mode 100644 index f5a8752..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus2.0 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -e= -test "${e:-\}}" = '}' diff --git a/tools/regression/bin/sh/expansion/plus-minus3.0 b/tools/regression/bin/sh/expansion/plus-minus3.0 deleted file mode 100644 index 49fcdc2..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus3.0 +++ /dev/null @@ -1,44 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -# We follow original ash behaviour for quoted ${var+-=?} expansions: -# a double-quote in one switches back to unquoted state. -# This allows expanding a variable as a single word if it is set -# and substituting multiple words otherwise. -# It is also close to the Bourne and Korn shells. -# POSIX leaves this undefined, and various other shells treat -# such double-quotes as introducing a second level of quoting -# which does not do much except quoting close braces. - -testcase 'set -- "${p+"/et[c]/"}"' '1|/etc/' -testcase 'set -- "${p-"/et[c]/"}"' '1|/et[c]/' -testcase 'set -- "${p+"$p"}"' '1|/etc/' -testcase 'set -- "${p-"$p"}"' '1|/et[c]/' -testcase 'set -- "${p+"""/et[c]/"}"' '1|/etc/' -testcase 'set -- "${p-"""/et[c]/"}"' '1|/et[c]/' -testcase 'set -- "${p+"""$p"}"' '1|/etc/' -testcase 'set -- "${p-"""$p"}"' '1|/et[c]/' -testcase 'set -- "${p+"\@"}"' '1|@' -testcase 'set -- "${p+"'\''/et[c]/'\''"}"' '1|/et[c]/' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/plus-minus4.0 b/tools/regression/bin/sh/expansion/plus-minus4.0 deleted file mode 100644 index 66dea38..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus4.0 +++ /dev/null @@ -1,38 +0,0 @@ -# $FreeBSD$ - -# These may be a bit unclear in the POSIX spec or the proposed revisions, -# and conflict with bash's interpretation, but I think ksh93's interpretation -# makes most sense. In particular, it makes no sense to me that single-quotes -# must match but are not removed. - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ${e:-'"'"'}'"'"'}' '1|}' -testcase "set -- \${e:-\\'}" "1|'" -testcase "set -- \${e:-\\'\\'}" "1|''" -testcase "set -- \"\${e:-'}\"" "1|'" -testcase "set -- \"\${e:-'}'}\"" "1|''}" -testcase "set -- \"\${e:-''}\"" "1|''" -testcase 'set -- ${e:-\a}' '1|a' -testcase 'set -- "${e:-\a}"' '1|\a' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/plus-minus5.0 b/tools/regression/bin/sh/expansion/plus-minus5.0 deleted file mode 100644 index 0b25e53..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus5.0 +++ /dev/null @@ -1,31 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ${e:-"{x}"}' '1|{x}' -testcase 'set -- "${e:-"{x}"}"' '1|{x}' -testcase 'set -- ${h+"{x}"}' '1|{x}' -testcase 'set -- "${h+"{x}"}"' '1|{x}' -testcase 'set -- ${h:-"{x}"}' '1|##' -testcase 'set -- "${h:-"{x}"}"' '1|##' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/plus-minus6.0 b/tools/regression/bin/sh/expansion/plus-minus6.0 deleted file mode 100644 index bc66805..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus6.0 +++ /dev/null @@ -1,34 +0,0 @@ -# $FreeBSD$ - -failures=0 -unset LC_ALL -export LC_CTYPE=en_US.ISO8859-1 -nl=' -' -i=1 -set -f -while [ "$i" -le 255 ]; do - # A different byte still in the range 1..255. - i2=$((i^2+(i==2))) - # Add a character to work around command substitution's removal of - # final newlines, then remove it again. - c=$(printf \\"$(printf %o@ "$i")") - c=${c%@} - c2=$(printf \\"$(printf %o@ "$i2")") - c2=${c2%@} - case $c in - [\'$nl'$}();&|\"`']) c=M - esac - case $c2 in - [\'$nl'$}();&|\"`']) c2=N - esac - IFS=$c - command eval "set -- \${\$+$c2$c$c2$c$c2}" - if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] || - [ "$3" != "$c2" ]; then - echo "Bad results for separator $i (word $i2)" >&2 - : $((failures += 1)) - fi - i=$((i+1)) -done -exit $((failures > 0)) diff --git a/tools/regression/bin/sh/expansion/plus-minus7.0 b/tools/regression/bin/sh/expansion/plus-minus7.0 deleted file mode 100644 index 9e81f58..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus7.0 +++ /dev/null @@ -1,26 +0,0 @@ -# $FreeBSD$ - -e= s='foo' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ${s+a b}' '2|a|b' -testcase 'set -- ${e:-a b}' '2|a|b' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/plus-minus8.0 b/tools/regression/bin/sh/expansion/plus-minus8.0 deleted file mode 100644 index beba009..0000000 --- a/tools/regression/bin/sh/expansion/plus-minus8.0 +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -set -- 1 2 3 4 5 6 7 8 9 10 11 12 13 -[ "${#+hi}" = hi ] || echo '${#+hi} wrong' -[ "${#-hi}" = 13 ] || echo '${#-hi} wrong' diff --git a/tools/regression/bin/sh/expansion/question1.0 b/tools/regression/bin/sh/expansion/question1.0 deleted file mode 100644 index 663c68d..0000000 --- a/tools/regression/bin/sh/expansion/question1.0 +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD$ - -x=a\ b -[ "$x" = "${x?}" ] || exit 1 -set -- ${x?} -{ [ "$#" = 2 ] && [ "$1" = a ] && [ "$2" = b ]; } || exit 1 -unset x -(echo ${x?abcdefg}) 2>&1 | grep -q abcdefg || exit 1 -${SH} -c 'unset foo; echo ${foo?}' 2>/dev/null && exit 1 -${SH} -c 'foo=; echo ${foo:?}' 2>/dev/null && exit 1 -${SH} -c 'foo=; echo ${foo?}' >/dev/null || exit 1 -${SH} -c 'foo=1; echo ${foo:?}' >/dev/null || exit 1 -${SH} -c 'echo ${!?}' 2>/dev/null && exit 1 -${SH} -c ':& echo ${!?}' >/dev/null || exit 1 -${SH} -c 'echo ${#?}' >/dev/null || exit 1 -${SH} -c 'echo ${*?}' 2>/dev/null && exit 1 -${SH} -c 'echo ${*?}' ${SH} x >/dev/null || exit 1 -${SH} -c 'echo ${1?}' 2>/dev/null && exit 1 -${SH} -c 'echo ${1?}' ${SH} x >/dev/null || exit 1 -${SH} -c 'echo ${2?}' ${SH} x 2>/dev/null && exit 1 -${SH} -c 'echo ${2?}' ${SH} x y >/dev/null || exit 1 -exit 0 diff --git a/tools/regression/bin/sh/expansion/readonly1.0 b/tools/regression/bin/sh/expansion/readonly1.0 deleted file mode 100644 index 5ad0e14..0000000 --- a/tools/regression/bin/sh/expansion/readonly1.0 +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ - -w='@ @' - -v=0 HOME=/known/value -readonly v=~:~/:$w -[ "$v" = "$HOME:$HOME/:$w" ] || echo "Expected $HOME/:$w got $v" diff --git a/tools/regression/bin/sh/expansion/set-u1.0 b/tools/regression/bin/sh/expansion/set-u1.0 deleted file mode 100644 index 763eb7d..0000000 --- a/tools/regression/bin/sh/expansion/set-u1.0 +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD$ - -${SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1 -${SH} -uc 'foo=; echo $foo' >/dev/null || exit 1 -${SH} -uc 'foo=1; echo $foo' >/dev/null || exit 1 -# -/+/= are unaffected by set -u -${SH} -uc 'unset foo; echo ${foo-}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo+}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo=}' >/dev/null || exit 1 -# length/trimming are affected -${SH} -uc 'unset foo; echo ${#foo}' 2>/dev/null && exit 1 -${SH} -uc 'foo=; echo ${#foo}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo#?}' 2>/dev/null && exit 1 -${SH} -uc 'foo=1; echo ${foo#?}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo##?}' 2>/dev/null && exit 1 -${SH} -uc 'foo=1; echo ${foo##?}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo%?}' 2>/dev/null && exit 1 -${SH} -uc 'foo=1; echo ${foo%?}' >/dev/null || exit 1 -${SH} -uc 'unset foo; echo ${foo%%?}' 2>/dev/null && exit 1 -${SH} -uc 'foo=1; echo ${foo%%?}' >/dev/null || exit 1 - -${SH} -uc 'echo $!' 2>/dev/null && exit 1 -${SH} -uc ':& echo $!' >/dev/null || exit 1 -${SH} -uc 'echo $#' >/dev/null || exit 1 -${SH} -uc 'echo $1' 2>/dev/null && exit 1 -${SH} -uc 'echo $1' ${SH} x >/dev/null || exit 1 -${SH} -uc 'echo $2' ${SH} x 2>/dev/null && exit 1 -${SH} -uc 'echo $2' ${SH} x y >/dev/null || exit 1 -exit 0 diff --git a/tools/regression/bin/sh/expansion/set-u2.0 b/tools/regression/bin/sh/expansion/set-u2.0 deleted file mode 100644 index f81aa62..0000000 --- a/tools/regression/bin/sh/expansion/set-u2.0 +++ /dev/null @@ -1,12 +0,0 @@ -# $FreeBSD$ - -set -u -: $* $@ "$@" "$*" -set -- x -: $* $@ "$@" "$*" -shift $# -: $* $@ "$@" "$*" -set -- y -set -- -: $* $@ "$@" "$*" -exit 0 diff --git a/tools/regression/bin/sh/expansion/set-u3.0 b/tools/regression/bin/sh/expansion/set-u3.0 deleted file mode 100644 index 7f199b4..0000000 --- a/tools/regression/bin/sh/expansion/set-u3.0 +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -set -u -unset x -v=$( (eval ': $((x))') 2>&1 >/dev/null) -[ $? -ne 0 ] && [ -n "$v" ] diff --git a/tools/regression/bin/sh/expansion/tilde1.0 b/tools/regression/bin/sh/expansion/tilde1.0 deleted file mode 100644 index 7d8581b..0000000 --- a/tools/regression/bin/sh/expansion/tilde1.0 +++ /dev/null @@ -1,56 +0,0 @@ -# $FreeBSD$ - -HOME=/tmp -roothome=~root -if [ "$roothome" = "~root" ]; then - echo "~root is not expanded!" - exit 2 -fi - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ~' '1|/tmp' -testcase 'set -- ~/foo' '1|/tmp/foo' -testcase 'set -- x~' '1|x~' -testcase 'set -- ~root' "1|$roothome" -h=~ -testcase 'set -- "$h"' '1|/tmp' -ooIFS=$IFS -IFS=m -testcase 'set -- ~' '1|/tmp' -testcase 'set -- ~/foo' '1|/tmp/foo' -testcase 'set -- $h' '2|/t|p' -IFS=$ooIFS -t=\~ -testcase 'set -- $t' '1|~' -r=$(cat <<EOF -~ -EOF -) -testcase 'set -- $r' '1|~' -r=$(cat <<EOF -${t+~} -EOF -) -testcase 'set -- $r' '1|~' -r=$(cat <<EOF -${t+~/.} -EOF -) -testcase 'set -- $r' '1|~/.' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/tilde2.0 b/tools/regression/bin/sh/expansion/tilde2.0 deleted file mode 100644 index 4f8ed9b..0000000 --- a/tools/regression/bin/sh/expansion/tilde2.0 +++ /dev/null @@ -1,90 +0,0 @@ -# $FreeBSD$ - -HOME=/tmp -roothome=~root -if [ "$roothome" = "~root" ]; then - echo "~root is not expanded!" - exit 2 -fi - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ${$+~}' '1|/tmp' -testcase 'set -- ${$+~/}' '1|/tmp/' -testcase 'set -- ${$+~/foo}' '1|/tmp/foo' -testcase 'set -- ${$+x~}' '1|x~' -testcase 'set -- ${$+~root}' "1|$roothome" -testcase 'set -- ${$+"~"}' '1|~' -testcase 'set -- ${$+"~/"}' '1|~/' -testcase 'set -- ${$+"~/foo"}' '1|~/foo' -testcase 'set -- ${$+"x~"}' '1|x~' -testcase 'set -- ${$+"~root"}' "1|~root" -testcase 'set -- "${$+~}"' '1|~' -testcase 'set -- "${$+~/}"' '1|~/' -testcase 'set -- "${$+~/foo}"' '1|~/foo' -testcase 'set -- "${$+x~}"' '1|x~' -testcase 'set -- "${$+~root}"' "1|~root" -testcase 'set -- ${HOME#~}' '0|' -h=~ -testcase 'set -- "$h"' '1|/tmp' -f=~/foo -testcase 'set -- "$f"' '1|/tmp/foo' -testcase 'set -- ${f#~}' '1|/foo' -testcase 'set -- ${f#~/}' '1|foo' - -ooIFS=$IFS -IFS=m -testcase 'set -- ${$+~}' '1|/tmp' -testcase 'set -- ${$+~/foo}' '1|/tmp/foo' -testcase 'set -- ${$+$h}' '2|/t|p' -testcase 'set -- ${HOME#~}' '0|' -IFS=$ooIFS - -t=\~ -testcase 'set -- ${$+$t}' '1|~' -r=$(cat <<EOF -${HOME#~} -EOF -) -testcase 'set -- $r' '0|' -r=$(cat <<EOF -${HOME#'~'} -EOF -) -testcase 'set -- $r' '1|/tmp' -r=$(cat <<EOF -${t#'~'} -EOF -) -testcase 'set -- $r' '0|' -r=$(cat <<EOF -${roothome#~root} -EOF -) -testcase 'set -- $r' '0|' -r=$(cat <<EOF -${f#~} -EOF -) -testcase 'set -- $r' '1|/foo' -r=$(cat <<EOF -${f#~/} -EOF -) -testcase 'set -- $r' '1|foo' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/trim1.0 b/tools/regression/bin/sh/expansion/trim1.0 deleted file mode 100644 index b548e52..0000000 --- a/tools/regression/bin/sh/expansion/trim1.0 +++ /dev/null @@ -1,85 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- ${t%t}' '1|texttex' -testcase 'set -- "${t%t}"' '1|texttex' -testcase 'set -- ${t%e*}' '1|textt' -testcase 'set -- "${t%e*}"' '1|textt' -testcase 'set -- ${t%%e*}' '1|t' -testcase 'set -- "${t%%e*}"' '1|t' -testcase 'set -- ${t%%*}' '0|' -testcase 'set -- "${t%%*}"' '1|' -testcase 'set -- ${t#t}' '1|exttext' -testcase 'set -- "${t#t}"' '1|exttext' -testcase 'set -- ${t#*x}' '1|ttext' -testcase 'set -- "${t#*x}"' '1|ttext' -testcase 'set -- ${t##*x}' '1|t' -testcase 'set -- "${t##*x}"' '1|t' -testcase 'set -- ${t##*}' '0|' -testcase 'set -- "${t##*}"' '1|' -testcase 'set -- ${t%e$a}' '1|textt' - -set -f -testcase 'set -- ${s%[?]*}' '1|ast*que' -testcase 'set -- "${s%[?]*}"' '1|ast*que' -testcase 'set -- ${s%[*]*}' '1|ast' -testcase 'set -- "${s%[*]*}"' '1|ast' -set +f - -testcase 'set -- $b' '1|{{(#)}}' -testcase 'set -- ${b%\}}' '1|{{(#)}' -testcase 'set -- ${b#{}' '1|{(#)}}' -testcase 'set -- "${b#{}"' '1|{(#)}}' -# Parentheses are special in ksh, check that they can be escaped -testcase 'set -- ${b%\)*}' '1|{{(#' -testcase 'set -- ${b#{}' '1|{(#)}}' -testcase 'set -- $h' '1|##' -testcase 'set -- ${h#\#}' '1|#' -testcase 'set -- ${h###}' '1|#' -testcase 'set -- "${h###}"' '1|#' -testcase 'set -- ${h%#}' '1|#' -testcase 'set -- "${h%#}"' '1|#' - -set -f -testcase 'set -- ${s%"${s#?}"}' '1|a' -testcase 'set -- ${s%"${s#????}"}' '1|ast*' -testcase 'set -- ${s%"${s#????????}"}' '1|ast*que?' -testcase 'set -- ${s#"${s%?}"}' '1|n' -testcase 'set -- ${s#"${s%????}"}' '1|?non' -testcase 'set -- ${s#"${s%????????}"}' '1|*que?non' -set +f -testcase 'set -- "${s%"${s#?}"}"' '1|a' -testcase 'set -- "${s%"${s#????}"}"' '1|ast*' -testcase 'set -- "${s%"${s#????????}"}"' '1|ast*que?' -testcase 'set -- "${s#"${s%?}"}"' '1|n' -testcase 'set -- "${s#"${s%????}"}"' '1|?non' -testcase 'set -- "${s#"${s%????????}"}"' '1|*que?non' -testcase 'set -- ${p#${p}}' '1|/etc/' -testcase 'set -- "${p#${p}}"' '1|/et[c]/' -testcase 'set -- ${p#*[[]}' '1|c]/' -testcase 'set -- "${p#*[[]}"' '1|c]/' -testcase 'set -- ${p#*\[}' '1|c]/' -testcase 'set -- ${p#*"["}' '1|c]/' -testcase 'set -- "${p#*"["}"' '1|c]/' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/trim2.0 b/tools/regression/bin/sh/expansion/trim2.0 deleted file mode 100644 index 619ef65..0000000 --- a/tools/regression/bin/sh/expansion/trim2.0 +++ /dev/null @@ -1,55 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -set -f -testcase 'set -- $s' '1|ast*que?non' -testcase 'set -- ${s%\?*}' '1|ast*que' -testcase 'set -- "${s%\?*}"' '1|ast*que' -testcase 'set -- ${s%\**}' '1|ast' -testcase 'set -- "${s%\**}"' '1|ast' -testcase 'set -- ${s%"$q"*}' '1|ast*que' -testcase 'set -- "${s%"$q"*}"' '1|ast*que' -testcase 'set -- ${s%"$a"*}' '1|ast' -testcase 'set -- "${s%"$a"*}"' '1|ast' -testcase 'set -- ${s%"$q"$a}' '1|ast*que' -testcase 'set -- "${s%"$q"$a}"' '1|ast*que' -testcase 'set -- ${s%"$a"$a}' '1|ast' -testcase 'set -- "${s%"$a"$a}"' '1|ast' -set +f - -testcase 'set -- "${b%\}}"' '1|{{(#)}' -# Parentheses are special in ksh, check that they can be escaped -testcase 'set -- "${b%\)*}"' '1|{{(#' -testcase 'set -- "${h#\#}"' '1|#' - -testcase 'set -- ${p%"${p#?}"}' '1|/' -testcase 'set -- ${p%"${p#??????}"}' '1|/etc' -testcase 'set -- ${p%"${p#???????}"}' '1|/etc/' -testcase 'set -- "${p%"${p#?}"}"' '1|/' -testcase 'set -- "${p%"${p#??????}"}"' '1|/et[c]' -testcase 'set -- "${p%"${p#???????}"}"' '1|/et[c]/' -testcase 'set -- ${p#"${p}"}' '0|' -testcase 'set -- "${p#"${p}"}"' '1|' -testcase 'set -- "${p#*\[}"' '1|c]/' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/trim3.0 b/tools/regression/bin/sh/expansion/trim3.0 deleted file mode 100644 index b89a041..0000000 --- a/tools/regression/bin/sh/expansion/trim3.0 +++ /dev/null @@ -1,46 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' c='\\\\' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -# This doesn't make much sense, but it fails in dash so I'm adding it here: -testcase 'set -- "${w%${w#???}}"' '1|a b' - -testcase 'set -- ${p#/et[}' '1|c]/' -testcase 'set -- "${p#/et[}"' '1|c]/' -testcase 'set -- "${p%${p#????}}"' '1|/et[' - -testcase 'set -- ${b%'\'}\''}' '1|{{(#)}' - -testcase 'set -- ${c#\\}' '1|\\\' -testcase 'set -- ${c#\\\\}' '1|\\' -testcase 'set -- ${c#\\\\\\}' '1|\' -testcase 'set -- ${c#\\\\\\\\}' '0|' -testcase 'set -- "${c#\\}"' '1|\\\' -testcase 'set -- "${c#\\\\}"' '1|\\' -testcase 'set -- "${c#\\\\\\}"' '1|\' -testcase 'set -- "${c#\\\\\\\\}"' '1|' -testcase 'set -- "${c#"$c"}"' '1|' -testcase 'set -- ${c#"$c"}' '0|' -testcase 'set -- "${c%"$c"}"' '1|' -testcase 'set -- ${c%"$c"}' '0|' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/trim4.0 b/tools/regression/bin/sh/expansion/trim4.0 deleted file mode 100644 index 1000bd3..0000000 --- a/tools/regression/bin/sh/expansion/trim4.0 +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD$ - -v1=/homes/SOME_USER -v2= -v3=C123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 - -# Trigger bug in VSTRIMRIGHT processing STADJUST() call in expand.c:subevalvar() -while [ ${#v2} -lt 2000 ]; do - v4="${v2} ${v1%/*} $v3" - if [ ${#v4} -ne $((${#v2} + ${#v3} + 8)) ]; then - echo bad: ${#v4} -ne $((${#v2} + ${#v3} + 8)) - fi - v2=x$v2 - v3=y$v3 -done diff --git a/tools/regression/bin/sh/expansion/trim5.0 b/tools/regression/bin/sh/expansion/trim5.0 deleted file mode 100644 index 937ec9a..0000000 --- a/tools/regression/bin/sh/expansion/trim5.0 +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' -h='##' -failures='' -ok='' - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- "${b%'\'}\''}"' '1|{{(#)}' -testcase 'set -- ${b%"}"}' '1|{{(#)}' -testcase 'set -- "${b%"}"}"' '1|{{(#)}' - -test "x$failures" = x diff --git a/tools/regression/bin/sh/expansion/trim6.0 b/tools/regression/bin/sh/expansion/trim6.0 deleted file mode 100644 index 3f753c4..0000000 --- a/tools/regression/bin/sh/expansion/trim6.0 +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD$ - -e= -for i in 0 1 2 3; do - for j in 0 1 2 3 4 5 6 7; do - for k in 0 1 2 3 4 5 6 7; do - case $i$j$k in - 000) continue ;; - esac - e="$e\\$i$j$k" - done - done -done -e=$(printf "$e") -v=@$e@$e@ -y=${v##*"$e"} -yq="${v##*"$e"}" -[ "$y" = @ ] || echo "error when unquoted in non-splitting context" -[ "$yq" = @ ] || echo "error when quoted in non-splitting context" -[ "${v##*"$e"}" = @ ] || echo "error when quoted in splitting context" -IFS= -[ ${v##*"$e"} = @ ] || echo "error when unquoted in splitting context" diff --git a/tools/regression/bin/sh/expansion/trim7.0 b/tools/regression/bin/sh/expansion/trim7.0 deleted file mode 100644 index 352bdea..0000000 --- a/tools/regression/bin/sh/expansion/trim7.0 +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ - -set -- 1 2 3 4 5 6 7 8 9 10 11 12 13 -[ "${##1}" = 3 ] || echo '${##1} wrong' -[ "${###1}" = 3 ] || echo '${###1} wrong' -[ "${###}" = 13 ] || echo '${###} wrong' -[ "${#%3}" = 1 ] || echo '${#%3} wrong' -[ "${#%%3}" = 1 ] || echo '${#%%3} wrong' -[ "${#%%}" = 13 ] || echo '${#%%} wrong' -set -- -[ "${##0}" = "" ] || echo '${##0} wrong' -[ "${###0}" = "" ] || echo '${###0} wrong' -[ "${###}" = 0 ] || echo '${###} wrong' -[ "${#%0}" = "" ] || echo '${#%0} wrong' -[ "${#%%0}" = "" ] || echo '${#%%0} wrong' -[ "${#%%}" = 0 ] || echo '${#%%} wrong' diff --git a/tools/regression/bin/sh/expansion/trim8.0 b/tools/regression/bin/sh/expansion/trim8.0 deleted file mode 100644 index f7272f3..0000000 --- a/tools/regression/bin/sh/expansion/trim8.0 +++ /dev/null @@ -1,75 +0,0 @@ -# $FreeBSD$ - -unset LC_ALL -LC_CTYPE=en_US.UTF-8 -export LC_CTYPE - -c1=e -# a umlaut -c2=$(printf '\303\244') -# euro sign -c3=$(printf '\342\202\254') -# some sort of 't' outside BMP -c4=$(printf '\360\235\225\245') - -s=$c1$c2$c3$c4 - -testcase() { - code="$1" - expected="$2" - oIFS="$IFS" - eval "$code" - IFS='|' - result="$#|$*" - IFS="$oIFS" - if [ "x$result" = "x$expected" ]; then - ok=x$ok - else - failures=x$failures - echo "For $code, expected $expected actual $result" - fi -} - -testcase 'set -- "$s"' "1|$s" -testcase 'set -- "${s#$c2}"' "1|$s" -testcase 'set -- "${s#*}"' "1|$s" -testcase 'set -- "${s#$c1}"' "1|$c2$c3$c4" -testcase 'set -- "${s#$c1$c2}"' "1|$c3$c4" -testcase 'set -- "${s#$c1$c2$c3}"' "1|$c4" -testcase 'set -- "${s#$c1$c2$c3$c4}"' "1|" -testcase 'set -- "${s#?}"' "1|$c2$c3$c4" -testcase 'set -- "${s#??}"' "1|$c3$c4" -testcase 'set -- "${s#???}"' "1|$c4" -testcase 'set -- "${s#????}"' "1|" -testcase 'set -- "${s#*$c3}"' "1|$c4" -testcase 'set -- "${s%$c4}"' "1|$c1$c2$c3" -testcase 'set -- "${s%$c3$c4}"' "1|$c1$c2" -testcase 'set -- "${s%$c2$c3$c4}"' "1|$c1" -testcase 'set -- "${s%$c1$c2$c3$c4}"' "1|" -testcase 'set -- "${s%?}"' "1|$c1$c2$c3" -testcase 'set -- "${s%??}"' "1|$c1$c2" -testcase 'set -- "${s%???}"' "1|$c1" -testcase 'set -- "${s%????}"' "1|" -testcase 'set -- "${s%$c2*}"' "1|$c1" -testcase 'set -- "${s##$c2}"' "1|$s" -testcase 'set -- "${s##*}"' "1|" -testcase 'set -- "${s##$c1}"' "1|$c2$c3$c4" -testcase 'set -- "${s##$c1$c2}"' "1|$c3$c4" -testcase 'set -- "${s##$c1$c2$c3}"' "1|$c4" -testcase 'set -- "${s##$c1$c2$c3$c4}"' "1|" -testcase 'set -- "${s##?}"' "1|$c2$c3$c4" -testcase 'set -- "${s##??}"' "1|$c3$c4" -testcase 'set -- "${s##???}"' "1|$c4" -testcase 'set -- "${s##????}"' "1|" -testcase 'set -- "${s##*$c3}"' "1|$c4" -testcase 'set -- "${s%%$c4}"' "1|$c1$c2$c3" -testcase 'set -- "${s%%$c3$c4}"' "1|$c1$c2" -testcase 'set -- "${s%%$c2$c3$c4}"' "1|$c1" -testcase 'set -- "${s%%$c1$c2$c3$c4}"' "1|" -testcase 'set -- "${s%%?}"' "1|$c1$c2$c3" -testcase 'set -- "${s%%??}"' "1|$c1$c2" -testcase 'set -- "${s%%???}"' "1|$c1" -testcase 'set -- "${s%%????}"' "1|" -testcase 'set -- "${s%%$c2*}"' "1|$c1" - -test "x$failures" = x |