aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-25 14:55:05 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-25 14:55:05 +0200
commit64925384c9cf5e0d986e183577da286bb3207ce7 (patch)
tree47688edcf2c0d987800968a9e9d85fc2cd0741e5 /shell/hush_test
parent73c47f6c41c97fb452b4747088543f2c2166830a (diff)
downloadbusybox-w32-64925384c9cf5e0d986e183577da286bb3207ce7.tar.gz
busybox-w32-64925384c9cf5e0d986e183577da286bb3207ce7.tar.bz2
busybox-w32-64925384c9cf5e0d986e183577da286bb3207ce7.zip
ash: add a few tests from hush-vars/*
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_alt.right1
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_alt.tests14
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_assign.tests27
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_bash_substring.tests13
4 files changed, 32 insertions, 23 deletions
diff --git a/shell/hush_test/hush-vars/param_expand_alt.right b/shell/hush_test/hush-vars/param_expand_alt.right
index 67f18d69c..4f9eb2907 100644
--- a/shell/hush_test/hush-vars/param_expand_alt.right
+++ b/shell/hush_test/hush-vars/param_expand_alt.right
@@ -1,6 +1,7 @@
1hush: syntax error: unterminated ${name} 1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name} 2hush: syntax error: unterminated ${name}
3__ __ 3__ __
4_z_ _z_
4_ _ _ _ _ 5_ _ _ _ _
5_aaaa _ _ _word _word 6_aaaa _ _ _word _word
6_ _ _ _ _ 7_ _ _ _ _
diff --git a/shell/hush_test/hush-vars/param_expand_alt.tests b/shell/hush_test/hush-vars/param_expand_alt.tests
index 3b646b142..c9c4249af 100755
--- a/shell/hush_test/hush-vars/param_expand_alt.tests
+++ b/shell/hush_test/hush-vars/param_expand_alt.tests
@@ -1,9 +1,15 @@
1# first try some invalid patterns (do in subshell due to parsing error) 1# First try some invalid patterns. Do in subshell due to parsing error.
2"$THIS_SH" -c 'echo ${+} ; echo moo' 2# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
3"$THIS_SH" -c 'echo ${:+} ; echo moo' 3"$THIS_SH" -c 'echo ${+} ; echo moo' SHELL
4"$THIS_SH" -c 'echo ${:+} ; echo moo' SHELL
4 5
5# now some funky ones. (bash doesn't accept ${#+}) 6# now some funky ones.
7# ${V+word} "if V unset, then substitute nothing, else substitute word"
8# ${V:+word} "if V unset or '', then substitute nothing, else substitute word"
9# bash doesn't accept ${#+}. ash prints 0 (not $#).
6echo _${#+}_ _${#:+}_ 10echo _${#+}_ _${#:+}_
11# Forms with non-empty word work as expected in both ash and bash.
12echo _${#+z}_ _${#:+z}_
7 13
8# now some valid ones 14# now some valid ones
9set -- 15set --
diff --git a/shell/hush_test/hush-vars/param_expand_assign.tests b/shell/hush_test/hush-vars/param_expand_assign.tests
index 149cb20df..79de95613 100755
--- a/shell/hush_test/hush-vars/param_expand_assign.tests
+++ b/shell/hush_test/hush-vars/param_expand_assign.tests
@@ -1,22 +1,23 @@
1# first try some invalid patterns (do in subshell due to parsing error) 1# First try some invalid patterns. Do in subshell due to parsing error.
2"$THIS_SH" -c 'echo ${=}' 2# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
3"$THIS_SH" -c 'echo ${:=}' 3"$THIS_SH" -c 'echo ${=}' SHELL
4"$THIS_SH" -c 'echo ${:=}' SHELL
4 5
5# now some funky ones 6# now some funky ones
6"$THIS_SH" -c 'echo ${#=}' 7"$THIS_SH" -c 'echo ${#=}' SHELL
7"$THIS_SH" -c 'echo ${#:=}' 8"$THIS_SH" -c 'echo ${#:=}' SHELL
8 9
9# should error out 10# should error out
10"$THIS_SH" -c 'set --; echo _${1=}' 11"$THIS_SH" -c 'set --; echo _${1=}' SHELL
11"$THIS_SH" -c 'set --; echo _${1:=}' 12"$THIS_SH" -c 'set --; echo _${1:=}' SHELL
12"$THIS_SH" -c 'set --; echo _${1=word}' 13"$THIS_SH" -c 'set --; echo _${1=word}' SHELL
13"$THIS_SH" -c 'set --; echo _${1:=word}' 14"$THIS_SH" -c 'set --; echo _${1:=word}' SHELL
14 15
15# should not error 16# should not error
16"$THIS_SH" -c 'set aa; echo _${1=}' 17"$THIS_SH" -c 'set aa; echo _${1=}' SHELL
17"$THIS_SH" -c 'set aa; echo _${1:=}' 18"$THIS_SH" -c 'set aa; echo _${1:=}' SHELL
18"$THIS_SH" -c 'set aa; echo _${1=word}' 19"$THIS_SH" -c 'set aa; echo _${1=word}' SHELL
19"$THIS_SH" -c 'set aa; echo _${1:=word}' 20"$THIS_SH" -c 'set aa; echo _${1:=word}' SHELL
20 21
21# should work fine 22# should work fine
22unset f; echo _$f 23unset f; echo _$f
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 5c9552dba..cce9f123e 100755
--- a/shell/hush_test/hush-vars/param_expand_bash_substring.tests
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
@@ -1,13 +1,14 @@
1# first try some invalid patterns 1# first try some invalid patterns
2# 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
3# (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
3export var=0123456789 4export var=0123456789
4"$THIS_SH" -c 'echo ${:}' 5"$THIS_SH" -c 'echo ${:}' SHELL
5"$THIS_SH" -c 'echo ${::}' 6"$THIS_SH" -c 'echo ${::}' SHELL
6"$THIS_SH" -c 'echo ${:1}' 7"$THIS_SH" -c 'echo ${:1}' SHELL
7"$THIS_SH" -c 'echo ${::1}' 8"$THIS_SH" -c 'echo ${::1}' SHELL
8 9
9#this also is not valid in bash, but we accept it: 10#this also is not valid in bash, hush accepts it:
10"$THIS_SH" -c 'echo ${var:}' 11"$THIS_SH" -c 'echo ${var:}' SHELL
11 12
12# then some funky ones 13# then some funky ones
13# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}' 14# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}'