busybox/shell/hush_test/hush-glob
Denys Vlasenko eb54ca8be0 ash: expand: Do not quote backslashes in unquoted parameter expansion
Upstream commit:

    Date: Wed, 28 Mar 2018 18:37:51 +0800
    expand: Do not quote backslashes in unquoted parameter expansion

    Here is a better example:

        a="/*/\nullx" b="/*/\null"; printf "%s\n" $a $b

    dash currently prints

        /*/\nullx
        /*/\null

    bash prints

        /*/\nullx
        /dev/null

    You may argue the bash behaviour is inconsistent but it actually
    makes sense.  What happens is that quote removal only applies to
    the original token as seen by the shell.  It is never applied to
    the result of parameter expansion.

    Now you may ask why on earth does the second line say "/dev/null"
    instead of "/dev/\null".  Well that's because it is not the quote
    removal step that removed the backslash, but the pathname expansion.

    The fact that the /de\v does not become /dev even though it exists
    is just the result of the optimisation to avoid unnecessarily
        calling stat(2).  I have checked POSIX and I don't see anything
    that forbids this behaviour.

    So going back to dash yes I think we should adopt the bash behaviour
    for pathname expansion and keep the existing case semantics.

    This patch does exactly that.  Note that this patch does not work
    unless you have already applied

        https://patchwork.kernel.org/patch/10306507/

    because otherwise the optimisation mentioned above does not get
    detected correctly and we will end up doing quote removal twice.

    This patch also updates expmeta to handle naked backslashes at
    the end of the pattern which is now possible.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

function                                             old     new   delta
expmeta                                              618     653     +35
memtodest                                            146     147      +1

Tested to work with both ASH_INTERNAL_GLOB on and off.

hush does not handle this correctly.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-07 18:58:02 +02:00
..
bash_brace1.right
bash_brace1.tests
glob1.right
glob1.tests hush: fix escaping of \[*?; add testsuites for these and for globbing 2008-06-10 20:13:40 +00:00
glob2.right hush: fix globbing+backslashes in unquoted $var expansion 2010-09-06 10:26:37 +02:00
glob2.tests
glob3.right ash,hush: add a test which fails for ash since commit 549deab 2015-09-04 03:33:02 +02:00
glob3.tests
glob_altvalue1.right hush: never glob result of dquoted "${v:+/bin/c*}" 2018-07-20 19:29:41 +02:00
glob_altvalue1.tests
glob_and_assign.right move glob_and_assign.tests from hush-bugs to hush-glob 2008-06-17 07:26:52 +00:00
glob_and_assign.tests move glob_and_assign.tests from hush-bugs to hush-glob 2008-06-17 07:26:52 +00:00
glob_bkslash_in_var.right ash: expand: Do not quote backslashes in unquoted parameter expansion 2018-08-07 18:58:02 +02:00
glob_bkslash_in_var.tests ash: expand: Do not quote backslashes in unquoted parameter expansion 2018-08-07 18:58:02 +02:00
glob_dir.right hush testsuite: add glob_dir.tests 2016-10-02 15:20:57 +02:00
glob_dir.tests hush testsuite: add glob_dir.tests 2016-10-02 15:20:57 +02:00
glob_redir.right hush: add testsuite for "no globbing in redirection" rule. 2008-06-18 16:29:32 +00:00
glob_redir.tests hush: add testsuite for "no globbing in redirection" rule. 2008-06-18 16:29:32 +00:00