]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/expansion/cmdsubst2.0
b86776ed24b017c34b4503d9ed404a74087e0a06
[apple/shell_cmds.git] / sh / tests / expansion / cmdsubst2.0
1 # $FreeBSD$
2
3 failures=0
4
5 check() {
6 if ! eval "[ $* ]"; then
7 echo "Failed: $*"
8 : $((failures += 1))
9 fi
10 }
11
12 check '`echo /et[c]/` = "/etc/"'
13 check '`printf /var/empty%s /et[c]/` = "/var/empty/etc/"'
14 check '"`echo /et[c]/`" = "/etc/"'
15 check '`echo "/et[c]/"` = "/etc/"'
16 check '`printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"'
17 check '`printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""'
18 check '"`echo \"/et[c]/\"`" = "/et[c]/"'
19 check '"`echo "/et[c]/"`" = "/et[c]/"'
20 check '`echo $$` = $$'
21 check '"`echo $$`" = $$'
22 check '`echo \$\$` = $$'
23 check '"`echo \$\$`" = $$'
24
25 # Command substitutions consisting of a single builtin may be treated
26 # differently.
27 check '`:; echo /et[c]/` = "/etc/"'
28 check '`:; printf /var/empty%s /et[c]/` = "/var/empty/etc/"'
29 check '"`:; echo /et[c]/`" = "/etc/"'
30 check '`:; echo "/et[c]/"` = "/etc/"'
31 check '`:; printf /var/empty%s "/et[c]/"` = "/var/empty/et[c]/"'
32 check '`:; printf /var/empty/%s \"/et[c]/\"` = "/var/empty/\"/et[c]/\""'
33 check '"`:; echo \"/et[c]/\"`" = "/et[c]/"'
34 check '"`:; echo "/et[c]/"`" = "/et[c]/"'
35 check '`:; echo $$` = $$'
36 check '"`:; echo $$`" = $$'
37 check '`:; echo \$\$` = $$'
38 check '"`:; echo \$\$`" = $$'
39
40 check '`set -f; echo /et[c]/` = "/etc/"'
41 check '"`set -f; echo /et[c]/`" = "/et[c]/"'
42
43 exit $((failures > 0))