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

Re: protect spaces and/or globs



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?

Lawrence:

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

BTW Peter I'm sure enjoying your User's Guide.  It should fortify me enough to finally read the manual.








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