xref: /freebsd/bin/sh/tests/expansion/cmdsubst1.0 (revision 02e9120893770924227138ba49df1edb3896112a)
1
2failures=0
3
4check() {
5	if ! eval "[ $* ]"; then
6		echo "Failed: $*"
7		: $((failures += 1))
8	fi
9}
10
11check '"$(echo abcde)" = "abcde"'
12check '"$(echo abcde; :)" = "abcde"'
13
14check '"$(printf abcde)" = "abcde"'
15check '"$(printf abcde; :)" = "abcde"'
16
17# regular
18check '-n "$(umask)"'
19check '-n "$(umask; :)"'
20check '-n "$(umask 2>&1)"'
21check '-n "$(umask 2>&1; :)"'
22
23# special
24check '-n "$(times)"'
25check '-n "$(times; :)"'
26check '-n "$(times 2>&1)"'
27check '-n "$(times 2>&1; :)"'
28
29# regular
30check '".$(umask -@ 2>&1)." = ".umask: Illegal option -@."'
31check '".$(umask -@ 2>&1; :)." = ".umask: Illegal option -@."'
32check '".$({ umask -@; } 2>&1)." = ".umask: Illegal option -@."'
33
34# special
35check '".$(shift xyz 2>&1)." = ".shift: Illegal number: xyz."'
36check '".$(shift xyz 2>&1; :)." = ".shift: Illegal number: xyz."'
37check '".$({ shift xyz; } 2>&1)." = ".shift: Illegal number: xyz."'
38
39v=1
40check '-z "$(v=2 :)"'
41check '"$v" = 1'
42check '-z "$(v=3)"'
43check '"$v" = 1'
44check '"$(v=4 eval echo \$v)" = 4'
45check '"$v" = 1'
46
47exit $((failures > 0))
48