aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-25 15:18:57 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-25 15:18:57 +0200
commit645c697372b714f1293a37a185aa62965f600479 (patch)
tree5033362b96737f83526b776818bf4c9a4ef8a9ef /shell/ash_test
parent64925384c9cf5e0d986e183577da286bb3207ce7 (diff)
downloadbusybox-w32-645c697372b714f1293a37a185aa62965f600479.tar.gz
busybox-w32-645c697372b714f1293a37a185aa62965f600479.tar.bz2
busybox-w32-645c697372b714f1293a37a185aa62965f600479.zip
hush: treat ${#?} as "length of $?"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-rw-r--r--shell/ash_test/ash-vars/param_expand_indicate_error.right43
-rwxr-xr-xshell/ash_test/ash-vars/param_expand_indicate_error.tests61
2 files changed, 104 insertions, 0 deletions
diff --git a/shell/ash_test/ash-vars/param_expand_indicate_error.right b/shell/ash_test/ash-vars/param_expand_indicate_error.right
new file mode 100644
index 000000000..33afacee0
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_indicate_error.right
@@ -0,0 +1,43 @@
1SHELL: line 1: syntax error: bad substitution
21
30
4====
5_
6SHELL: line 1: 1: parameter not set
7SHELL: line 1: 1: parameter not set or null
8SHELL: line 1: 1: message1
9SHELL: line 1: 1: message1
10SHELL: line 1: 1: unset!
11SHELL: line 1: 1: null or unset!
12====
13_aaaa
14_aaaa
15_aaaa
16_aaaa
17_aaaa
18_aaaa
19_aaaa
20====
21_
22SHELL: line 1: f: parameter not set
23SHELL: line 1: f: parameter not set or null
24SHELL: line 1: f: message3
25SHELL: line 1: f: message3
26SHELL: line 1: f: unset!
27SHELL: line 1: f: null or unset!
28====
29_
30_
31SHELL: line 1: f: parameter not set or null
32_
33SHELL: line 1: f: message4
34_
35SHELL: line 1: f: null or unset!
36====
37_fff
38_fff
39_fff
40_fff
41_fff
42_fff
43_fff
diff --git a/shell/ash_test/ash-vars/param_expand_indicate_error.tests b/shell/ash_test/ash-vars/param_expand_indicate_error.tests
new file mode 100755
index 000000000..0f3061949
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_indicate_error.tests
@@ -0,0 +1,61 @@
1# do all of these in subshells since it's supposed to error out
2# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
3
4# first try some invalid patterns
5#"$THIS_SH" -c 'echo ${?}' SHELL -- this is valid as it's the same as $?
6"$THIS_SH" -c 'echo ${:?}' SHELL
7
8# then some funky ones
9# note: bash prints 1 - treats it as "length of $#"
10"$THIS_SH" -c 'echo ${#?}' SHELL
11# bash prints 0
12"$THIS_SH" -c 'echo ${#:?}' SHELL
13
14# now some valid ones
15export msg_unset="unset!"
16export msg_null_or_unset="null or unset!"
17
18echo ====
19"$THIS_SH" -c 'set --; echo _$1' SHELL
20"$THIS_SH" -c 'set --; echo _${1?}' SHELL
21"$THIS_SH" -c 'set --; echo _${1:?}' SHELL
22"$THIS_SH" -c 'set --; echo _${1?message1}' SHELL
23"$THIS_SH" -c 'set --; echo _${1:?message1}' SHELL
24"$THIS_SH" -c 'set --; echo _${1?$msg_unset}' SHELL
25"$THIS_SH" -c 'set --; echo _${1:?$msg_null_or_unset}' SHELL
26
27echo ====
28"$THIS_SH" -c 'set -- aaaa; echo _$1' SHELL
29"$THIS_SH" -c 'set -- aaaa; echo _${1?}' SHELL
30"$THIS_SH" -c 'set -- aaaa; echo _${1:?}' SHELL
31"$THIS_SH" -c 'set -- aaaa; echo _${1?word}' SHELL
32"$THIS_SH" -c 'set -- aaaa; echo _${1:?word}' SHELL
33"$THIS_SH" -c 'set -- aaaa; echo _${1?$msg_unset}' SHELL
34"$THIS_SH" -c 'set -- aaaa; echo _${1:?$msg_null_or_unset}' SHELL
35
36echo ====
37"$THIS_SH" -c 'unset f; echo _$f' SHELL
38"$THIS_SH" -c 'unset f; echo _${f?}' SHELL
39"$THIS_SH" -c 'unset f; echo _${f:?}' SHELL
40"$THIS_SH" -c 'unset f; echo _${f?message3}' SHELL
41"$THIS_SH" -c 'unset f; echo _${f:?message3}' SHELL
42"$THIS_SH" -c 'unset f; echo _${f?$msg_unset}' SHELL
43"$THIS_SH" -c 'unset f; echo _${f:?$msg_null_or_unset}' SHELL
44
45echo ====
46"$THIS_SH" -c 'f=; echo _$f' SHELL
47"$THIS_SH" -c 'f=; echo _${f?}' SHELL
48"$THIS_SH" -c 'f=; echo _${f:?}' SHELL
49"$THIS_SH" -c 'f=; echo _${f?word}' SHELL
50"$THIS_SH" -c 'f=; echo _${f:?message4}' SHELL
51"$THIS_SH" -c 'f=; echo _${f?$msg_unset}' SHELL
52"$THIS_SH" -c 'f=; echo _${f:?$msg_null_or_unset}' SHELL
53
54echo ====
55"$THIS_SH" -c 'f=fff; echo _$f' SHELL
56"$THIS_SH" -c 'f=fff; echo _${f?}' SHELL
57"$THIS_SH" -c 'f=fff; echo _${f:?}' SHELL
58"$THIS_SH" -c 'f=fff; echo _${f?word}' SHELL
59"$THIS_SH" -c 'f=fff; echo _${f:?word}' SHELL
60"$THIS_SH" -c 'f=fff; echo _${f?$msg_unset}' SHELL
61"$THIS_SH" -c 'f=fff; echo _${f:?$msg_null_or_unset}' SHELL