Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: protect spaces and/or globs



> On Feb 9, 2021, at 6:45 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> 
> On 2021-02-09 1:08 p.m., Peter Stephenson wrote:
>> 
>>> In this case, actually, all you're doing is the equivalent of
>>> a single array assignment.
>>> 
>>> filespec=("$@")
>>> 
>>> pws
> It doesn't seem to solve the problem.  Here's a real example:
> 
> $ g ,H 'execute' 'g,46,w4 now default' f
> ... The search string is 'execute' and the two target files follow. But after zsh is finished stripping of the quotes the final grep command looks like this:
> 
> GREP_COLOR='01;33' grep --color=always -iFIHn -d skip -- 'execute' g,46,w4 now default  f
> 
> ... and of course it won't work due to the spaces.  Input via an array seems to make no difference.  (Unless I'm doing it wrong.)  If I do this:
> 
> $ g ,H 'execute' 'g,46,w4\ now\ default' f
> ... I get:
> 
> GREP_COLOR='01;33' grep --color=always -iFIHn -d skip -- 'execute' g,46,w4\ now\ default  f
> ... which works fine.  Finally,:
> 
> $ g ,H 'execute' g,46,w4\ now\ default f
> ... gives:
> 
> GREP_COLOR='01;33' grep --color=always -iFIHn -d skip -- 'execute' g,46,w4 now default  f
> ... and again the unquoted spaces screw it up.  Is there any way to force the single quotes to pass through as literals?

How are you assembling the grep command? How are you executing it?

> Lawrence:
> 
> It's all rather complicated, my wrappers do all sorts of mischief before calling grep.

For the less clairvoyant of us, your refusal to reveal anything but
the smallest slice of your actual code makes it rather difficult
to help.

vq



Messages sorted by: Reverse Date, Date, Thread, Author