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