diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-06 19:48:20 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-06 19:48:20 +0200 |
commit | 5dad7bdc3bdad8e9934d45301d5a8c51e843cd7b (patch) | |
tree | db493d6ca6cabddcfe3e9a58f33ee712bd1584d4 /shell/hush_test | |
parent | 3234045d07c3fb2a9ef8afd02f821158317adbd3 (diff) | |
download | busybox-w32-5dad7bdc3bdad8e9934d45301d5a8c51e843cd7b.tar.gz busybox-w32-5dad7bdc3bdad8e9934d45301d5a8c51e843cd7b.tar.bz2 busybox-w32-5dad7bdc3bdad8e9934d45301d5a8c51e843cd7b.zip |
hush: implement negative start in the ${v: -n[:m]} idiom
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r-- | shell/hush_test/hush-vars/var_bash1a.right | 6 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var_bash1a.tests | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/shell/hush_test/hush-vars/var_bash1a.right b/shell/hush_test/hush-vars/var_bash1a.right new file mode 100644 index 000000000..1965b5c6c --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash1a.right | |||
@@ -0,0 +1,6 @@ | |||
1 | parameter 'abcdef' | ||
2 | varoffset2 'cdef' | ||
3 | varoffset-2 'ef' | ||
4 | literal '2' 'cdef' | ||
5 | literal '-2' 'abcdef' | ||
6 | literal ' -2' 'ef' | ||
diff --git a/shell/hush_test/hush-vars/var_bash1a.tests b/shell/hush_test/hush-vars/var_bash1a.tests new file mode 100755 index 000000000..551dd9acc --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash1a.tests | |||
@@ -0,0 +1,11 @@ | |||
1 | parameter=abcdef | ||
2 | offset=2 | ||
3 | noffset=-2 | ||
4 | echo "parameter '${parameter}'" | ||
5 | echo "varoffset2 '${parameter:${offset}}'" | ||
6 | echo "varoffset-2 '${parameter:${noffset}}'" | ||
7 | echo "literal '2' '${parameter:2}'" | ||
8 | # This is not inrpreted as ${VAR:POS{:LEN}}, | ||
9 | # but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD | ||
10 | echo "literal '-2' '${parameter:-2}'" | ||
11 | echo "literal ' -2' '${parameter: -2}'" | ||