From c49d2d97939d77be3d1f3bbbbf9db30a55771c15 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 6 Sep 2010 10:26:37 +0200 Subject: hush: fix globbing+backslashes in unquoted $var expansion Signed-off-by: Denys Vlasenko --- shell/hush_test/hush-glob/glob2.tests | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 shell/hush_test/hush-glob/glob2.tests (limited to 'shell/hush_test/hush-glob/glob2.tests') diff --git a/shell/hush_test/hush-glob/glob2.tests b/shell/hush_test/hush-glob/glob2.tests new file mode 100755 index 000000000..4dbc92599 --- /dev/null +++ b/shell/hush_test/hush-glob/glob2.tests @@ -0,0 +1,27 @@ +# This test demonstrates that in unquoted $v, backslashes expand by this rule: +# \z -> \\\z; \ -> \\ (for any z, special or not), +# and subsequently globbing converts \\ to \ and treats \z as literal z +# even if it is a special char. + +>'Zf' +>'Z\f' + echo 'Expected' 'Actual' +v='\*'; echo 'Z\* :' Z$v + echo 'Z* :' Z\* + echo 'Z\f :' Z\\* + echo 'Z\* :' Z\\\* # NB! only this matches Z$v output +echo +v='\z'; echo 'Z\z :' Z$v + echo 'Zz :' Z\z + echo 'Z\z :' Z\\z + echo 'Z\z :' Z\\\z +echo +v='\'; echo 'Z\ :' Z$v + echo 'Z\ :' Z\\ +echo +v='*'; echo 'Z\f Zf :' Z$v + echo 'Z\f Zf :' Z* +echo + +rm 'Z\f' 'Zf' +echo Done: $? -- cgit v1.2.3