zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: greps pipes and eval bad patterns
Date: Sun, 25 Oct 2015 12:47:15 -0700	[thread overview]
Message-ID: <562D31C3.9030705@eastlink.ca> (raw)

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.)





             reply	other threads:[~2015-10-25 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-25 19:47 Ray Andrews [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=562D31C3.9030705@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).