aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-vars
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash_test/ash-vars')
-rwxr-xr-xshell/ash_test/ash-vars/param_expand_alt.tests2
-rw-r--r--shell/ash_test/ash-vars/param_expand_len1.right11
-rwxr-xr-xshell/ash_test/ash-vars/param_expand_len1.tests31
3 files changed, 43 insertions, 1 deletions
diff --git a/shell/ash_test/ash-vars/param_expand_alt.tests b/shell/ash_test/ash-vars/param_expand_alt.tests
index c9c4249af..d80452434 100755
--- a/shell/ash_test/ash-vars/param_expand_alt.tests
+++ b/shell/ash_test/ash-vars/param_expand_alt.tests
@@ -6,7 +6,7 @@
# now some funky ones.
# ${V+word} "if V unset, then substitute nothing, else substitute word"
# ${V:+word} "if V unset or '', then substitute nothing, else substitute word"
-# bash doesn't accept ${#+}. ash prints 0 (not $#).
+# bash doesn't accept ${#+}. ash prints 0 (not $#): "len of $+"
echo _${#+}_ _${#:+}_
# Forms with non-empty word work as expected in both ash and bash.
echo _${#+z}_ _${#:+z}_
diff --git a/shell/ash_test/ash-vars/param_expand_len1.right b/shell/ash_test/ash-vars/param_expand_len1.right
new file mode 100644
index 000000000..dff3c7bb1
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_len1.right
@@ -0,0 +1,11 @@
+One:1
+Two:2
+Three:3
+
+One:1
+Two:2
+Three:3
+
+Ok ${#$}: 0
+
+Ok ${#!}: 0
diff --git a/shell/ash_test/ash-vars/param_expand_len1.tests b/shell/ash_test/ash-vars/param_expand_len1.tests
new file mode 100755
index 000000000..e1beab320
--- /dev/null
+++ b/shell/ash_test/ash-vars/param_expand_len1.tests
@@ -0,0 +1,31 @@
+# ${#c} for any single char c means "length of $c", including all special vars
+
+false
+echo One:${#?}
+(exit 10)
+echo Two:${#?}
+(exit 100)
+echo Three:${#?}
+
+echo
+echo One:${##}
+set -- 1 2 3 4 5 6 7 8 9 0
+echo Two:${##}
+set -- 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
+ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
+ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 \
+ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
+echo Three:${##}
+
+echo
+v=$$
+test "${#v}" = "${#$}"
+echo 'Ok ${#$}:' $?
+
+echo
+sleep 0 &
+v=$!
+test "${#v}" = "${#!}"
+echo 'Ok ${#!}:' $?
+
+# TODO: ${#-} ${#_}