zsh-users
 help / color / mirror / code / Atom feed
* greps pipes and eval bad patterns
@ 2015-10-25 19:47 Ray Andrews
  2015-10-26  1:02 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Ray Andrews @ 2015-10-25 19:47 UTC (permalink / raw)
  To: Zsh Users

Gentlemen:

test1 ()
{
     gstring=" | grep \[01;34m "
     tree --du -haC | grep -Ev "^[^\[]{$levels}\[*" "$gstring"
}

That's a cut down version of my 'tree' wrapper. If $gstring is appended 
as it's literal content (as opposed to the variable itself) it works 
fine, but if I use the variable as shown , grep tries to eat it as part 
of it's own argument string. I've solved problems like that elsewhere by 
using 'eval' however it doesn't work in the above situation because eval 
complains about the contents of the first grep search:

(eval):1: bad pattern: ^[^[]{12}[*

As a point of principal can this be done?  The thing would be to stop 
$gstring from being interpreted as an argument to the first grep and I'm 
betting it's easy if you know how.  In practice my wrapper uses two 
separate lines, one with and one without the " | grep \[01;34m " (Which, 
BTW, selects directories only for display based on the color of the 
output of 'tree'--blue for directories.) But it would be elegant to use 
one line, and append $gstring (set to null or to the above depending on 
whether I want directories only as the output, or not.)





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-26 14:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-25 19:47 greps pipes and eval bad patterns Ray Andrews
2015-10-26  1:02 ` Bart Schaefer
2015-10-26  1:17   ` Kurtis Rader
2015-10-26  3:39     ` Ray Andrews
2015-10-26  3:31   ` Ray Andrews
2015-10-26 13:04     ` ZyX
2015-10-26 13:36       ` Ray Andrews
2015-10-26 14:30         ` Bart Schaefer
2015-10-26 14:49           ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).