[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Backslash mysteriously disappears in command expansion when unescapi

From: Robert Elz
Subject: Re: Backslash mysteriously disappears in command expansion when unescaping would reference an existing file
Date: Wed, 22 May 2019 17:25:43 +0700

    Date:        Tue, 21 May 2019 22:11:20 +0000
    From:        Charles-Henri Gros <address@hidden>
    Message-ID:  <address@hidden>

  | The existence or not of the file should not have any effect.

But it does, and is intended to.   If the mattern matches a file
(when patyhname expanded as a result of the unquoted command substitution)
you get the file name produced.   If it does not match a file,
the pattern is left untouched.   That is the way that things are
supposed to work.

I suspect that you meant to say

        for i in "$(echo "a\\\$.class")"; do echo "$i"; done

then there would be no pathname expansion happening (more correctly,
there still is, but the pathname to be expanded contains no magic
chars, only chars that match literally, so you either get the file
with the exact same name, or the pattern untouched, which is the same
thing - shells generally optimise away the attempt to match in that
case, as the result is always known in advance).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]