diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 13:20:14 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-21 13:20:14 +0200 |
commit | 42ba757d5e80ba25cc192939aa3525049f9e092f (patch) | |
tree | c89b3d378eb9f98eed81466122e269554a81400a /shell/ash_test | |
parent | 168f0ef8ddb6c840662bd15bad86177b0d238120 (diff) | |
download | busybox-w32-42ba757d5e80ba25cc192939aa3525049f9e092f.tar.gz busybox-w32-42ba757d5e80ba25cc192939aa3525049f9e092f.tar.bz2 busybox-w32-42ba757d5e80ba25cc192939aa3525049f9e092f.zip |
ash: improve set -x to quote strings as necessary
Basen on the patch from Martijn Dekker <martijn@inlv.org>
function old new delta
evalcommand 1161 1302 +141
maybe_single_quote - 60 +60
getoptscmd 527 546 +19
readtoken1 2819 2823 +4
localcmd 366 364 -2
evaltreenr 495 479 -16
evaltree 495 479 -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 224/-34) Total: 190 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-rw-r--r-- | shell/ash_test/ash-quoting/mode_x.right | 10 | ||||
-rwxr-xr-x | shell/ash_test/ash-quoting/mode_x.tests | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/shell/ash_test/ash-quoting/mode_x.right b/shell/ash_test/ash-quoting/mode_x.right new file mode 100644 index 000000000..c2dd3550c --- /dev/null +++ b/shell/ash_test/ash-quoting/mode_x.right | |||
@@ -0,0 +1,10 @@ | |||
1 | + var1=val | ||
2 | + var2='one two' | ||
3 | + true '%s\n' one 'two '"'"'three' four | ||
4 | + this=command | ||
5 | + 'this=command' | ||
6 | ./mode_x.tests: line 1: this=command: not found | ||
7 | + true | ||
8 | + true | ||
9 | + 'if' true | ||
10 | ./mode_x.tests: line 1: if: not found | ||
diff --git a/shell/ash_test/ash-quoting/mode_x.tests b/shell/ash_test/ash-quoting/mode_x.tests new file mode 100755 index 000000000..16dae3f4b --- /dev/null +++ b/shell/ash_test/ash-quoting/mode_x.tests | |||
@@ -0,0 +1,14 @@ | |||
1 | set -x | ||
2 | |||
3 | var1=val | ||
4 | var2='one two' | ||
5 | true %s\\n one "two 'three" four | ||
6 | |||
7 | # assignment: | ||
8 | this=command | ||
9 | # NOT assignment, +x code should show it quoted: | ||
10 | "this=command" | ||
11 | |||
12 | if true; then true; fi | ||
13 | # +x code should quote 'if' here: | ||
14 | "if" true | ||