busybox/shell/ash_test/ash-vars/var_bash1a.tests
Denys Vlasenko f8ddbe1ccc ash: fix handling of ${VAR: -2}
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25 03:56:00 +02:00

12 lines
393 B
Plaintext
Executable File

parameter=abcdef
offset=2
noffset=-2
echo "parameter '${parameter}'"
echo "varoffset2 '${parameter:${offset}}'"
echo "varoffset-2 '${parameter:${noffset}}'"
echo "literal '2' '${parameter:2}'"
# This is not inrpreted as ${VAR:POS{:LEN}},
# but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD
echo "literal '-2' '${parameter:-2}'"
echo "literal ' -2' '${parameter: -2}'"