shell: tweak bkslash_in_varexp.tests, add bkslash_in_varexp1.tests

It turns out bkslash_in_varexp.tests was a bash bug :]

ash and hush fail "corrected" bkslash_in_varexp.tests as well,
just not as badly as I thought (hush gets half of the cases right).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2018-03-02 18:12:12 +01:00
parent 744a20d8f9
commit 55f8133a4f
8 changed files with 50 additions and 5 deletions

View File

@@ -1,4 +1,14 @@
x=a
x='a]'
#
# \] is not a valid escape for ] in set glob expression.
# Glob sets have no escaping at all:
# ] can be in a set if it is the first char: []abc],
# dash can be in a set if it is first or last: [abc-],
# [ and \ need no protections at all: [a[b\c] is a valid set of 5 chars.
#
# bash-4.3.43 misinterprets [a\]] as "set of 'a' or ']'".
# Correct interpretation is "set of 'a' or '\', followed by ']'".
#
echo Nothing:${x#[a\]]}
echo Nothing:"${x#[a\]]}"
echo Nothing:${x%[a\]]}

View File

@@ -0,0 +1,5 @@
Nothing:
Nothing:
Nothing:
Nothing:
Ok:0

View File

@@ -0,0 +1,6 @@
x=a
echo Nothing:${x#[]a]}
echo Nothing:"${x#[]a]}"
echo Nothing:${x%[]a]}
echo Nothing:"${x%[]a]}"
echo Ok:$?