diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 00:26:06 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 00:26:06 +0200 |
commit | a6ad397ea92cd9c53973243728d3e52640fe63ec (patch) | |
tree | 058f34aaf8877c15a1c667efaa491267f046c7e7 /shell/hush_test | |
parent | 7436950a7516d1f4498285ccc81bf6d926f3af5e (diff) | |
download | busybox-w32-a6ad397ea92cd9c53973243728d3e52640fe63ec.tar.gz busybox-w32-a6ad397ea92cd9c53973243728d3e52640fe63ec.tar.bz2 busybox-w32-a6ad397ea92cd9c53973243728d3e52640fe63ec.zip |
hush: fix more obscure ${var%...} cases
function old new delta
add_till_closing_paren 313 359 +46
builtin_exit 48 47 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r-- | shell/hush_test/hush-arith/arith.right | 9 | ||||
-rwxr-xr-x | shell/hush_test/hush-arith/arith.tests | 19 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/var_posix1.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var_posix1.tests | 1 |
4 files changed, 22 insertions, 8 deletions
diff --git a/shell/hush_test/hush-arith/arith.right b/shell/hush_test/hush-arith/arith.right index 83155fb03..718c26ad0 100644 --- a/shell/hush_test/hush-arith/arith.right +++ b/shell/hush_test/hush-arith/arith.right | |||
@@ -43,21 +43,30 @@ Format: 'expected actual' | |||
43 | 4 4 | 43 | 4 4 |
44 | 29 29 | 44 | 29 29 |
45 | 5 5 | 45 | 5 5 |
46 | unary plus, minus | ||
46 | -4 -4 | 47 | -4 -4 |
47 | 4 4 | 48 | 4 4 |
49 | conditional expressions | ||
48 | 1 1 | 50 | 1 1 |
49 | 32 32 | 51 | 32 32 |
50 | 32 32 | 52 | 32 32 |
51 | 1 1 | 53 | 1 1 |
52 | 1 1 | 54 | 1 1 |
53 | 32 32 | 55 | 32 32 |
56 | check that parentheses in `cmd` are interpreted correctly | ||
57 | 3 3 | ||
58 | check that the unevaluated part of the ternary operator does not do evaluation or assignment | ||
54 | 20 20 | 59 | 20 20 |
55 | 30 30 | 60 | 30 30 |
56 | 20 20 | 61 | 20 20 |
57 | 30 30 | 62 | 30 30 |
63 | check precedence of assignment vs. conditional operator | ||
58 | hush: error in arithmetic | 64 | hush: error in arithmetic |
65 | check precedence of assignment vs. conditional operator | ||
66 | associativity of assignment-operator operator | ||
59 | 6 6 | 67 | 6 6 |
60 | 6,5,3 6,5,3 | 68 | 6,5,3 6,5,3 |
69 | octal, hex | ||
61 | 263 263 | 70 | 263 263 |
62 | 255 255 | 71 | 255 255 |
63 | 40 40 | 72 | 40 40 |
diff --git a/shell/hush_test/hush-arith/arith.tests b/shell/hush_test/hush-arith/arith.tests index 57e66e888..bc6b341d1 100755 --- a/shell/hush_test/hush-arith/arith.tests +++ b/shell/hush_test/hush-arith/arith.tests | |||
@@ -75,11 +75,11 @@ echo 4 $(( iv &= 4 )) | |||
75 | echo 29 $(( iv += (jv + 9))) | 75 | echo 29 $(( iv += (jv + 9))) |
76 | echo 5 $(( (iv + 4) % 7 )) | 76 | echo 5 $(( (iv + 4) % 7 )) |
77 | 77 | ||
78 | # unary plus, minus | 78 | echo unary plus, minus |
79 | echo -4 $(( +4 - 8 )) | 79 | echo -4 $(( +4 - 8 )) |
80 | echo 4 $(( -4 + 8 )) | 80 | echo 4 $(( -4 + 8 )) |
81 | 81 | ||
82 | # conditional expressions | 82 | echo conditional expressions |
83 | echo 1 $(( 4<5 ? 1 : 32)) | 83 | echo 1 $(( 4<5 ? 1 : 32)) |
84 | echo 32 $(( 4>5 ? 1 : 32)) | 84 | echo 32 $(( 4>5 ? 1 : 32)) |
85 | echo 32 $(( 4>(2+3) ? 1 : 32)) | 85 | echo 32 $(( 4>(2+3) ? 1 : 32)) |
@@ -87,8 +87,11 @@ echo 1 $(( 4<(2+3) ? 1 : 32)) | |||
87 | echo 1 $(( (2+2)<(2+3) ? 1 : 32)) | 87 | echo 1 $(( (2+2)<(2+3) ? 1 : 32)) |
88 | echo 32 $(( (2+2)>(2+3) ? 1 : 32)) | 88 | echo 32 $(( (2+2)>(2+3) ? 1 : 32)) |
89 | 89 | ||
90 | # check that the unevaluated part of the ternary operator does not do | 90 | echo 'check that parentheses in `cmd` are interpreted correctly' |
91 | # evaluation or assignment | 91 | # \x28 is '(' |
92 | echo 3 $(( ( `printf '(\x28 1'` + `echo 2\)\)` ) )) | ||
93 | |||
94 | echo check that the unevaluated part of the ternary operator does not do evaluation or assignment | ||
92 | x=i+=2 | 95 | x=i+=2 |
93 | y=j+=2 | 96 | y=j+=2 |
94 | #ash# declare -i i=1 j=1 | 97 | #ash# declare -i i=1 j=1 |
@@ -109,20 +112,20 @@ echo 20 $((1 ? 20 : (x+=2))) | |||
109 | echo 30 $((0 ? (y+=2) : 30)) | 112 | echo 30 $((0 ? (y+=2) : 30)) |
110 | #ash# echo $i,$y # ash mishandles this | 113 | #ash# echo $i,$y # ash mishandles this |
111 | 114 | ||
112 | # check precedence of assignment vs. conditional operator | 115 | echo check precedence of assignment vs. conditional operator |
113 | # should be an error | 116 | # should be an error |
114 | #ash# declare -i x=2 | 117 | #ash# declare -i x=2 |
115 | x=2 | 118 | x=2 |
116 | #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: | 119 | #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: |
117 | ( y=$((1 ? 20 : x+=2)) ) | 120 | ( y=$((1 ? 20 : x+=2)) ) |
118 | 121 | ||
119 | # check precedence of assignment vs. conditional operator | 122 | echo check precedence of assignment vs. conditional operator |
120 | #ash# declare -i x=2 | 123 | #ash# declare -i x=2 |
121 | x=2 | 124 | x=2 |
122 | # ash says "line NNN: syntax error: 0 ? x+=2 : 20" | 125 | # ash says "line NNN: syntax error: 0 ? x+=2 : 20" |
123 | #ash# echo 20 $((0 ? x+=2 : 20)) | 126 | #ash# echo 20 $((0 ? x+=2 : 20)) |
124 | 127 | ||
125 | # associativity of assignment-operator operator | 128 | echo associativity of assignment-operator operator |
126 | #ash# declare -i i=1 j=2 k=3 | 129 | #ash# declare -i i=1 j=2 k=3 |
127 | i=1 | 130 | i=1 |
128 | j=2 | 131 | j=2 |
@@ -130,7 +133,7 @@ k=3 | |||
130 | echo 6 $((i += j += k)) | 133 | echo 6 $((i += j += k)) |
131 | echo 6,5,3 $i,$j,$k | 134 | echo 6,5,3 $i,$j,$k |
132 | 135 | ||
133 | # octal, hex | 136 | echo octal, hex |
134 | echo 263 $(( 0x100 | 007 )) | 137 | echo 263 $(( 0x100 | 007 )) |
135 | echo 255 $(( 0xff )) | 138 | echo 255 $(( 0xff )) |
136 | #ash# echo 255 $(( 16#ff )) | 139 | #ash# echo 255 $(( 16#ff )) |
diff --git a/shell/hush_test/hush-vars/var_posix1.right b/shell/hush_test/hush-vars/var_posix1.right index 813437e2f..7ff618ad0 100644 --- a/shell/hush_test/hush-vars/var_posix1.right +++ b/shell/hush_test/hush-vars/var_posix1.right | |||
@@ -37,4 +37,5 @@ ababcdcd_tail | |||
37 | ababcdcd | 37 | ababcdcd |
38 | ab | 38 | ab |
39 | ab | 39 | ab |
40 | ab | ||
40 | End | 41 | End |
diff --git a/shell/hush_test/hush-vars/var_posix1.tests b/shell/hush_test/hush-vars/var_posix1.tests index e48fd98c7..82abe8198 100755 --- a/shell/hush_test/hush-vars/var_posix1.tests +++ b/shell/hush_test/hush-vars/var_posix1.tests | |||
@@ -47,5 +47,6 @@ echo ${var%\\*} | |||
47 | 47 | ||
48 | a=ab}; echo ${a%\}}; | 48 | a=ab}; echo ${a%\}}; |
49 | a=abc; c=c; echo ${a%${c}} | 49 | a=abc; c=c; echo ${a%${c}} |
50 | a=ab{{c; echo ${a%`echo {{c`} | ||
50 | 51 | ||
51 | echo End | 52 | echo End |