summaryrefslogtreecommitdiffstats
path: root/bin/sh/tests/expansion/cmdsubst1.0
blob: 515c7da9aca1305e719af0e6dd1a1696dd01585d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# $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))
OpenPOWER on IntegriCloud