tilde2.0 revision 303975
1221828Sgrehan# $FreeBSD: releng/11.0/bin/sh/tests/expansion/tilde2.0 206150 2010-04-03 22:04:44Z jilles $ 2221828Sgrehan 3221828SgrehanHOME=/tmp 4221828Sgrehanroothome=~root 5276403Sneelif [ "$roothome" = "~root" ]; then 6276403Sneel echo "~root is not expanded!" 7276429Sneel exit 2 8221828Sgrehanfi 9221914Sjhb 10254596Suqstestcase() { 11254596Suqs code="$1" 12221828Sgrehan expected="$2" 13276403Sneel oIFS="$IFS" 14221828Sgrehan eval "$code" 15221828Sgrehan IFS='|' 16221828Sgrehan result="$#|$*" 17221828Sgrehan IFS="$oIFS" 18221828Sgrehan if [ "x$result" = "x$expected" ]; then 19242275Sneel ok=x$ok 20240941Sneel else 21268891Sjhb failures=x$failures 22221828Sgrehan echo "For $code, expected $expected actual $result" 23221828Sgrehan fi 24221828Sgrehan} 25221828Sgrehan 26221828Sgrehantestcase 'set -- ${$+~}' '1|/tmp' 27221828Sgrehantestcase 'set -- ${$+~/}' '1|/tmp/' 28221828Sgrehantestcase 'set -- ${$+~/foo}' '1|/tmp/foo' 29221828Sgrehantestcase 'set -- ${$+x~}' '1|x~' 30221828Sgrehantestcase 'set -- ${$+~root}' "1|$roothome" 31221828Sgrehantestcase 'set -- ${$+"~"}' '1|~' 32221828Sgrehantestcase 'set -- ${$+"~/"}' '1|~/' 33268891Sjhbtestcase 'set -- ${$+"~/foo"}' '1|~/foo' 34268891Sjhbtestcase 'set -- ${$+"x~"}' '1|x~' 35261088Sjhbtestcase 'set -- ${$+"~root"}' "1|~root" 36261088Sjhbtestcase 'set -- "${$+~}"' '1|~' 37276429Sneeltestcase 'set -- "${$+~/}"' '1|~/' 38276429Sneeltestcase 'set -- "${$+~/foo}"' '1|~/foo' 39221828Sgrehantestcase 'set -- "${$+x~}"' '1|x~' 40221828Sgrehantestcase 'set -- "${$+~root}"' "1|~root" 41221828Sgrehantestcase 'set -- ${HOME#~}' '0|' 42221828Sgrehanh=~ 43221828Sgrehantestcase 'set -- "$h"' '1|/tmp' 44221828Sgrehanf=~/foo 45276386Sneeltestcase 'set -- "$f"' '1|/tmp/foo' 46221828Sgrehantestcase 'set -- ${f#~}' '1|/foo' 47221828Sgrehantestcase 'set -- ${f#~/}' '1|foo' 48221828Sgrehan 49221828SgrehanooIFS=$IFS 50221828SgrehanIFS=m 51276403Sneeltestcase 'set -- ${$+~}' '1|/tmp' 52276403Sneeltestcase 'set -- ${$+~/foo}' '1|/tmp/foo' 53276403Sneeltestcase 'set -- ${$+$h}' '2|/t|p' 54276403Sneeltestcase 'set -- ${HOME#~}' '0|' 55276403SneelIFS=$ooIFS 56276403Sneel 57276429Sneelt=\~ 58276403Sneeltestcase 'set -- ${$+$t}' '1|~' 59221828Sgrehanr=$(cat <<EOF 60276386Sneel${HOME#~} 61221828SgrehanEOF 62276386Sneel) 63221828Sgrehantestcase 'set -- $r' '0|' 64221828Sgrehanr=$(cat <<EOF 65221828Sgrehan${HOME#'~'} 66276403SneelEOF 67276403Sneel) 68276403Sneeltestcase 'set -- $r' '1|/tmp' 69276403Sneelr=$(cat <<EOF 70276403Sneel${t#'~'} 71276403SneelEOF 72276386Sneel) 73221828Sgrehantestcase 'set -- $r' '0|' 74221828Sgrehanr=$(cat <<EOF 75221828Sgrehan${roothome#~root} 76276403SneelEOF 77276403Sneel) 78276403Sneeltestcase 'set -- $r' '0|' 79276403Sneelr=$(cat <<EOF 80276386Sneel${f#~} 81221828SgrehanEOF 82221828Sgrehan) 83276403Sneeltestcase 'set -- $r' '1|/foo' 84276403Sneelr=$(cat <<EOF 85276403Sneel${f#~/} 86221828SgrehanEOF 87) 88testcase 'set -- $r' '1|foo' 89 90test "x$failures" = x 91