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