aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-21 01:15:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-21 01:15:42 +0200
commit4d8e5fdc1d4bb14ebfecdf6ce19e15024103659f (patch)
treeda52c662b6253597bcaa9a0f5cfa5f2d75c0164d /shell/hush_test
parent53b513331add89e83c1327579f3da91ebbe97570 (diff)
downloadbusybox-w32-4d8e5fdc1d4bb14ebfecdf6ce19e15024103659f.tar.gz
busybox-w32-4d8e5fdc1d4bb14ebfecdf6ce19e15024103659f.tar.bz2
busybox-w32-4d8e5fdc1d4bb14ebfecdf6ce19e15024103659f.zip
hush: optional support for ${var:N:M} bashism
function old new delta expand_vars_to_list 1999 2183 +184 handle_dollar 682 623 -59 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-vars/param_expand_bash_substring.right29
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_bash_substring.tests46
2 files changed, 75 insertions, 0 deletions
diff --git a/shell/hush_test/hush-vars/param_expand_bash_substring.right b/shell/hush_test/hush-vars/param_expand_bash_substring.right
new file mode 100644
index 000000000..9cd465938
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.right
@@ -0,0 +1,29 @@
1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
3hush: syntax error: unterminated ${name}
4hush: syntax error: unterminated ${name}
50123456789
61 =||
71:1 =||
81:1:2=||
91::2 =||
101 =|0123|
111:1 =|123|
121:1:2=|12|
131::2 =|01|
14f =||
15f:1 =||
16f:1:2=||
17f::2 =||
18f =||
19f:1 =||
20f:1:2=||
21f::2 =||
22f =|a|
23f:1 =||
24f:1:2=||
25f::2 =|a|
26f =|0123456789|
27f:1 =|123456789|
28f:1:2=|12|
29f::2 =|01|
diff --git a/shell/hush_test/hush-vars/param_expand_bash_substring.tests b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
new file mode 100755
index 000000000..6a1765559
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
@@ -0,0 +1,46 @@
1# do all of these in subshells since it's supposed to error out
2
3export var=0123456789
4
5# first try some invalid patterns
6"$THIS_SH" -c 'echo ${:}'
7"$THIS_SH" -c 'echo ${::}'
8"$THIS_SH" -c 'echo ${:1}'
9"$THIS_SH" -c 'echo ${::1}'
10
11#this also is not valid in bash, but we accept it:
12"$THIS_SH" -c 'echo ${var:}'
13
14# then some funky ones
15# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}'
16
17# now some valid ones
18"$THIS_SH" -c 'set --; echo "1 =|${1}|"'
19"$THIS_SH" -c 'set --; echo "1:1 =|${1:1}|"'
20"$THIS_SH" -c 'set --; echo "1:1:2=|${1:1:2}|"'
21"$THIS_SH" -c 'set --; echo "1::2 =|${1::2}|"'
22
23"$THIS_SH" -c 'set -- 0123; echo "1 =|${1}|"'
24"$THIS_SH" -c 'set -- 0123; echo "1:1 =|${1:1}|"'
25"$THIS_SH" -c 'set -- 0123; echo "1:1:2=|${1:1:2}|"'
26"$THIS_SH" -c 'set -- 0123; echo "1::2 =|${1::2}|"'
27
28"$THIS_SH" -c 'unset f; echo "f =|$f|"'
29"$THIS_SH" -c 'unset f; echo "f:1 =|${f:1}|"'
30"$THIS_SH" -c 'unset f; echo "f:1:2=|${f:1:2}|"'
31"$THIS_SH" -c 'unset f; echo "f::2 =|${f::2}|"'
32
33"$THIS_SH" -c 'f=; echo "f =|$f|"'
34"$THIS_SH" -c 'f=; echo "f:1 =|${f:1}|"'
35"$THIS_SH" -c 'f=; echo "f:1:2=|${f:1:2}|"'
36"$THIS_SH" -c 'f=; echo "f::2 =|${f::2}|"'
37
38"$THIS_SH" -c 'f=a; echo "f =|$f|"'
39"$THIS_SH" -c 'f=a; echo "f:1 =|${f:1}|"'
40"$THIS_SH" -c 'f=a; echo "f:1:2=|${f:1:2}|"'
41"$THIS_SH" -c 'f=a; echo "f::2 =|${f::2}|"'
42
43"$THIS_SH" -c 'f=0123456789; echo "f =|$f|"'
44"$THIS_SH" -c 'f=0123456789; echo "f:1 =|${f:1}|"'
45"$THIS_SH" -c 'f=0123456789; echo "f:1:2=|${f:1:2}|"'
46"$THIS_SH" -c 'f=0123456789; echo "f::2 =|${f::2}|"'