blob: 83644988365b0c8d4d5ef8cad7c45510196ba365 (
plain) (
blame)
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: releng/12.0/bin/sh/tests/expansion/cmdsubst1.0 201366 2010-01-01 18:17:46Z jilles $
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))
|