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

Re: protect spaces and/or globs

On 2021-02-09 4:22 p.m., Lawrence Velázquez wrote:
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.

I'm trying to keep is as simple as possible because the totality of the thing doesn't matter, just the specific problem.  When a function argument will end up making an argument to grep, and the argument to grep must have single quotes, but the single quotes typed in the function argument are stripped off. What's the solution? grep must have " $ grep 'file name'  " with intact quotes but zsh always strips them off.   There must be a solution.  Or perhaps I'm stuck with " $ grep 'file\ name' -- seems the single quotes preserve the backlash which in turn forces 'file name' to be a single word as wanted.  It's ok, but I wonder if there's a better way.  I thought the (q) flag might
do it.  Memory tickles that I learned how to do this once.

Hey, just fiddling around with it right now and:

$ g ,H 'execute' "'g,46,w4 now default'" f
... double quote the single quotes and the single quotes remain. Logical too, outer
quotes will be stripped, so just throw in another set.  Final grep is:

GREP_COLOR='01;33' grep --color=always -iFIHn -d skip -- 'execute' 'g,46,w4 now default' f
... all good.

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