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

Re: protect spaces and/or globs



On 2021-02-09 5:46 p.m., Lawrence Velázquez wrote:

... which youhave already decided is an ulcer and cannot possibly be anything
other than an ulcer.
It would take far too long to explain the whole show.  If you have the time and interest contact me privately and I'll show you what I'm up to.  But I already waste far too much
of the list's time.

It sure sounds like you're assembling a scalar and eval-ing it,

That's exactly what I'm doing. But far more.

% () { eval "print -rC1 -- ${(q)@}" } a 'b c' d 'e f g'
	a
	b c
	d
	e f g


Thing is that if those args were going to grep and they were filenames you'd end up with:

$ grep [some search string] a b c d e f g
... whereas your filenames are 'a'   'b c'   d   and   'e  f  g'.
The single quotes must be preserved or the spaces backslashed.  But as  I just posted, double quoting the whole filespec:

"a 'b c' d 'e f g' "
... appears to be working fine.  grep looks in four files not seven.   Seems the double quotes preserve the single quotes.






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