]> git.saurik.com Git - apple/shell_cmds.git/blame - sh/tests/expansion/plus-minus4.0
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / tests / expansion / plus-minus4.0
CommitLineData
deb63bfb 1# $FreeBSD: head/bin/sh/tests/expansion/plus-minus4.0 211080 2010-08-08 17:03:23Z jilles $
71aad674
A
2
3# These may be a bit unclear in the POSIX spec or the proposed revisions,
4# and conflict with bash's interpretation, but I think ksh93's interpretation
5# makes most sense. In particular, it makes no sense to me that single-quotes
6# must match but are not removed.
7
8e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
9h='##'
10failures=''
11ok=''
12
13testcase() {
14 code="$1"
15 expected="$2"
16 oIFS="$IFS"
17 eval "$code"
18 IFS='|'
19 result="$#|$*"
20 IFS="$oIFS"
21 if [ "x$result" = "x$expected" ]; then
22 ok=x$ok
23 else
24 failures=x$failures
25 echo "For $code, expected $expected actual $result"
26 fi
27}
28
29testcase 'set -- ${e:-'"'"'}'"'"'}' '1|}'
30testcase "set -- \${e:-\\'}" "1|'"
31testcase "set -- \${e:-\\'\\'}" "1|''"
32testcase "set -- \"\${e:-'}\"" "1|'"
33testcase "set -- \"\${e:-'}'}\"" "1|''}"
34testcase "set -- \"\${e:-''}\"" "1|''"
35testcase 'set -- ${e:-\a}' '1|a'
36testcase 'set -- "${e:-\a}"' '1|\a'
37
38test "x$failures" = x