aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-22 03:12:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-22 03:12:29 +0200
commit1e811b12317d0eab4e78d848caa640cca497a0a7 (patch)
treeef60262af7944dfe557542bec9e1fb8bea367b60 /shell/hush_test
parentddc62f64baad8abdeb587b13afe8d47fb347981c (diff)
downloadbusybox-w32-1e811b12317d0eab4e78d848caa640cca497a0a7.tar.gz
busybox-w32-1e811b12317d0eab4e78d848caa640cca497a0a7.tar.bz2
busybox-w32-1e811b12317d0eab4e78d848caa640cca497a0a7.zip
hush: support ${var:EXPR:EXPR}!
function old new delta handle_dollar 574 681 +107 expand_and_evaluate_arith - 77 +77 expand_vars_to_list 2302 2374 +72 add_till_closing_bracket 359 368 +9 builtin_exit 48 47 -1 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/1 up/down: 265/-1) Total: 264 bytes 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.right10
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_bash_substring.tests98
2 files changed, 64 insertions, 44 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
index 6e3eb3ba6..53b8836ff 100644
--- a/shell/hush_test/hush-vars/param_expand_bash_substring.right
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.right
@@ -39,3 +39,13 @@ f:1:2=|12|
39f::2 =|01| 39f::2 =|01|
40f:1: =|| 40f:1: =||
41f:: =|| 41f:: =||
42Substrings with expressions
43f =|01234567|
44f:1+1:2+2 =|2345|
45f:-1:2+2 =|01234567|
46f:1:f =|1234567|
47f:1:$f =|1234567|
48f:1:${f} =|1234567|
49f:1:${f:3:1} =|123|
50f:1:1`echo 1`=|1|
51Done
diff --git a/shell/hush_test/hush-vars/param_expand_bash_substring.tests b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
index eedd435ed..a80523add 100755
--- a/shell/hush_test/hush-vars/param_expand_bash_substring.tests
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
@@ -1,8 +1,6 @@
1# first try some invalid patterns
1# do all of these in subshells since it's supposed to error out 2# do all of these in subshells since it's supposed to error out
2
3export var=0123456789 3export var=0123456789
4
5# first try some invalid patterns
6"$THIS_SH" -c 'echo ${:}' 4"$THIS_SH" -c 'echo ${:}'
7"$THIS_SH" -c 'echo ${::}' 5"$THIS_SH" -c 'echo ${::}'
8"$THIS_SH" -c 'echo ${:1}' 6"$THIS_SH" -c 'echo ${:1}'
@@ -15,44 +13,56 @@ export var=0123456789
15# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}' 13# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}'
16 14
17# now some valid ones 15# now some valid ones
18"$THIS_SH" -c 'set --; echo "1 =|${1}|"' 16set --; echo "1 =|${1}|"
19"$THIS_SH" -c 'set --; echo "1:1 =|${1:1}|"' 17set --; echo "1:1 =|${1:1}|"
20"$THIS_SH" -c 'set --; echo "1:1:2=|${1:1:2}|"' 18set --; echo "1:1:2=|${1:1:2}|"
21"$THIS_SH" -c 'set --; echo "1::2 =|${1::2}|"' 19set --; echo "1::2 =|${1::2}|"
22"$THIS_SH" -c 'set --; echo "1:1: =|${1:1:}|"' 20set --; echo "1:1: =|${1:1:}|"
23"$THIS_SH" -c 'set --; echo "1:: =|${1::}|"' 21set --; echo "1:: =|${1::}|"
24 22
25"$THIS_SH" -c 'set -- 0123; echo "1 =|${1}|"' 23set -- 0123; echo "1 =|${1}|"
26"$THIS_SH" -c 'set -- 0123; echo "1:1 =|${1:1}|"' 24set -- 0123; echo "1:1 =|${1:1}|"
27"$THIS_SH" -c 'set -- 0123; echo "1:1:2=|${1:1:2}|"' 25set -- 0123; echo "1:1:2=|${1:1:2}|"
28"$THIS_SH" -c 'set -- 0123; echo "1::2 =|${1::2}|"' 26set -- 0123; echo "1::2 =|${1::2}|"
29"$THIS_SH" -c 'set -- 0123; echo "1:1: =|${1:1:}|"' 27set -- 0123; echo "1:1: =|${1:1:}|"
30"$THIS_SH" -c 'set -- 0123; echo "1:: =|${1::}|"' 28set -- 0123; echo "1:: =|${1::}|"
31 29
32"$THIS_SH" -c 'unset f; echo "f =|$f|"' 30unset f; echo "f =|$f|"
33"$THIS_SH" -c 'unset f; echo "f:1 =|${f:1}|"' 31unset f; echo "f:1 =|${f:1}|"
34"$THIS_SH" -c 'unset f; echo "f:1:2=|${f:1:2}|"' 32unset f; echo "f:1:2=|${f:1:2}|"
35"$THIS_SH" -c 'unset f; echo "f::2 =|${f::2}|"' 33unset f; echo "f::2 =|${f::2}|"
36"$THIS_SH" -c 'unset f; echo "f:1: =|${f:1:}|"' 34unset f; echo "f:1: =|${f:1:}|"
37"$THIS_SH" -c 'unset f; echo "f:: =|${f::}|"' 35unset f; echo "f:: =|${f::}|"
38 36
39"$THIS_SH" -c 'f=; echo "f =|$f|"' 37f=; echo "f =|$f|"
40"$THIS_SH" -c 'f=; echo "f:1 =|${f:1}|"' 38f=; echo "f:1 =|${f:1}|"
41"$THIS_SH" -c 'f=; echo "f:1:2=|${f:1:2}|"' 39f=; echo "f:1:2=|${f:1:2}|"
42"$THIS_SH" -c 'f=; echo "f::2 =|${f::2}|"' 40f=; echo "f::2 =|${f::2}|"
43"$THIS_SH" -c 'f=; echo "f:1: =|${f:1:}|"' 41f=; echo "f:1: =|${f:1:}|"
44"$THIS_SH" -c 'f=; echo "f:: =|${f::}|"' 42f=; echo "f:: =|${f::}|"
45 43
46"$THIS_SH" -c 'f=a; echo "f =|$f|"' 44f=a; echo "f =|$f|"
47"$THIS_SH" -c 'f=a; echo "f:1 =|${f:1}|"' 45f=a; echo "f:1 =|${f:1}|"
48"$THIS_SH" -c 'f=a; echo "f:1:2=|${f:1:2}|"' 46f=a; echo "f:1:2=|${f:1:2}|"
49"$THIS_SH" -c 'f=a; echo "f::2 =|${f::2}|"' 47f=a; echo "f::2 =|${f::2}|"
50"$THIS_SH" -c 'f=a; echo "f:1: =|${f:1:}|"' 48f=a; echo "f:1: =|${f:1:}|"
51"$THIS_SH" -c 'f=a; echo "f:: =|${f::}|"' 49f=a; echo "f:: =|${f::}|"
52 50
53"$THIS_SH" -c 'f=0123456789; echo "f =|$f|"' 51f=0123456789; echo "f =|$f|"
54"$THIS_SH" -c 'f=0123456789; echo "f:1 =|${f:1}|"' 52f=0123456789; echo "f:1 =|${f:1}|"
55"$THIS_SH" -c 'f=0123456789; echo "f:1:2=|${f:1:2}|"' 53f=0123456789; echo "f:1:2=|${f:1:2}|"
56"$THIS_SH" -c 'f=0123456789; echo "f::2 =|${f::2}|"' 54f=0123456789; echo "f::2 =|${f::2}|"
57"$THIS_SH" -c 'f=0123456789; echo "f:1: =|${f:1:}|"' 55f=0123456789; echo "f:1: =|${f:1:}|"
58"$THIS_SH" -c 'f=0123456789; echo "f:: =|${f::}|"' 56f=0123456789; echo "f:: =|${f::}|"
57
58echo "Substrings with expressions"
59f=01234567; echo 'f '"=|$f|"
60f=01234567; echo 'f:1+1:2+2 '"=|${f:1+1:2+2}|"
61f=01234567; echo 'f:-1:2+2 '"=|${f:-1:2+2}|"
62f=01234567; echo 'f:1:f '"=|${f:1:f}|"
63f=01234567; echo 'f:1:$f '"=|${f:1:$f}|"
64f=01234567; echo 'f:1:${f} '"=|${f:1:${f}}|"
65f=01234567; echo 'f:1:${f:3:1} '"=|${f:1:${f:3:1}}|"
66f=01234567; echo 'f:1:1`echo 1`'"=|${f:1:`echo 1`}|"
67
68echo Done