ash: expand: Use HOME in tilde expansion when it is empty
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 17:31:05 +0000 (18:31 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 16 Feb 2020 18:16:35 +0000 (19:16 +0100)
Upstream commit:

    Date: Sun, 27 May 2018 17:31:57 +0800
    expand: Use HOME in tilde expansion when it is empty

    Currently if HOME is set to empty tilde expansion will fail, i.e.,
    it will remain as a literal tilde.  This patch changes it to
    return the empty string as required by POSIX.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index 78ca1d99c19be50e1ecb16eeb7683c967d72a674..138f19abdaeb7681c1aa8449f56208d4d9bab486 100644 (file)
@@ -6440,7 +6440,7 @@ exptilde(char *startp, char *p, int flags)
                        goto lose;
                home = pw->pw_dir;
        }
-       if (!home || !*home)
+       if (!home)
                goto lose;
        *p = c;
        strtodest(home, SQSYNTAX, quotes);