bug-bash
[Top][All Lists]
Advanced

[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: Thu, 23 May 2019 09:08:00 +0700

    Date:        Wed, 22 May 2019 22:23:04 +0000
    From:        Charles-Henri Gros <address@hidden>
    Message-ID:  <address@hidden>

  | But unfortunately, grep was just illustrative, I'm using another tool
  | that takes a regex but has no "-F" option (though admittedly with some
  | effort I could add one, I wrote the tool in question).

You can still do the sed to hide any $ in the command line the way
you were doing.   The important thing is to not expose the results
to pathname expansion, and if you're going to use the shell to
break apart the file names (field splitting) make sure IFS is set
correctly - you might find
        IFS=$'\n'
works better for your usage than the default (so filenames with
spaces don't give problems).

You might also want to use Chet's suggestion, and disable pathname
expansion with "set -f".

But this kind of thing is what happens when you don't povide all of
the info about the problem you're having - people tend to provide
answers to the problem you say that you have, rather than the
actual issue.

It is all good (and helpful) to find a simple test case for a problem
you're seeing, and provide that as well - but always give the actual
problem details.

Here without knowing what kind of input your "tool in question" takes
it is impossible for anyone to work out what a good solution would be.

  | Yes I'm not expecting any special characters except "$".

It is best not to make too many assumptions - remember that even '.'
is special in RE's and '.' is very common in filenames.

kre




reply via email to

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