aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-vars/param_expand_bash_substring.right29
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_bash_substring.tests46
2 files changed, 75 insertions, 0 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
new file mode 100644
index 000000000..9cd465938
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.right
@@ -0,0 +1,29 @@
+hush: syntax error: unterminated ${name}
+hush: syntax error: unterminated ${name}
+hush: syntax error: unterminated ${name}
+hush: syntax error: unterminated ${name}
+0123456789
+1 =||
+1:1 =||
+1:1:2=||
+1::2 =||
+1 =|0123|
+1:1 =|123|
+1:1:2=|12|
+1::2 =|01|
+f =||
+f:1 =||
+f:1:2=||
+f::2 =||
+f =||
+f:1 =||
+f:1:2=||
+f::2 =||
+f =|a|
+f:1 =||
+f:1:2=||
+f::2 =|a|
+f =|0123456789|
+f:1 =|123456789|
+f:1:2=|12|
+f::2 =|01|
diff --git a/shell/hush_test/hush-vars/param_expand_bash_substring.tests b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
new file mode 100755
index 000000000..6a1765559
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_bash_substring.tests
@@ -0,0 +1,46 @@
+# do all of these in subshells since it's supposed to error out
+
+export var=0123456789
+
+# first try some invalid patterns
+"$THIS_SH" -c 'echo ${:}'
+"$THIS_SH" -c 'echo ${::}'
+"$THIS_SH" -c 'echo ${:1}'
+"$THIS_SH" -c 'echo ${::1}'
+
+#this also is not valid in bash, but we accept it:
+"$THIS_SH" -c 'echo ${var:}'
+
+# then some funky ones
+# UNFIXED BUG: this should work: "$THIS_SH" -c 'echo ${?:0}'
+
+# now some valid ones
+"$THIS_SH" -c 'set --; echo "1 =|${1}|"'
+"$THIS_SH" -c 'set --; echo "1:1 =|${1:1}|"'
+"$THIS_SH" -c 'set --; echo "1:1:2=|${1:1:2}|"'
+"$THIS_SH" -c 'set --; echo "1::2 =|${1::2}|"'
+
+"$THIS_SH" -c 'set -- 0123; echo "1 =|${1}|"'
+"$THIS_SH" -c 'set -- 0123; echo "1:1 =|${1:1}|"'
+"$THIS_SH" -c 'set -- 0123; echo "1:1:2=|${1:1:2}|"'
+"$THIS_SH" -c 'set -- 0123; echo "1::2 =|${1::2}|"'
+
+"$THIS_SH" -c 'unset f; echo "f =|$f|"'
+"$THIS_SH" -c 'unset f; echo "f:1 =|${f:1}|"'
+"$THIS_SH" -c 'unset f; echo "f:1:2=|${f:1:2}|"'
+"$THIS_SH" -c 'unset f; echo "f::2 =|${f::2}|"'
+
+"$THIS_SH" -c 'f=; echo "f =|$f|"'
+"$THIS_SH" -c 'f=; echo "f:1 =|${f:1}|"'
+"$THIS_SH" -c 'f=; echo "f:1:2=|${f:1:2}|"'
+"$THIS_SH" -c 'f=; echo "f::2 =|${f::2}|"'
+
+"$THIS_SH" -c 'f=a; echo "f =|$f|"'
+"$THIS_SH" -c 'f=a; echo "f:1 =|${f:1}|"'
+"$THIS_SH" -c 'f=a; echo "f:1:2=|${f:1:2}|"'
+"$THIS_SH" -c 'f=a; echo "f::2 =|${f::2}|"'
+
+"$THIS_SH" -c 'f=0123456789; echo "f =|$f|"'
+"$THIS_SH" -c 'f=0123456789; echo "f:1 =|${f:1}|"'
+"$THIS_SH" -c 'f=0123456789; echo "f:1:2=|${f:1:2}|"'
+"$THIS_SH" -c 'f=0123456789; echo "f::2 =|${f::2}|"'