From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 710 invoked by alias); 26 Oct 2015 01:02:41 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20820 Received: (qmail 21915 invoked from network); 26 Oct 2015 01:02:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=WxL2jsjCU3wu0XYrR35zJFOmQQZd3h1ej/5U2auf78Q=; b=MqFtKtLQnxHYb/RAK78BNuvqJotwVLjdO3fzguwni/AFetkEdYLDmmfAoO3s8kvNmm QxwkA9yZ0HMW+Cg8ENOLryMpyocIgBTcrOlUGO5mUladbZKtSZyFyFhdxS7p/4cARDyu 86vtFd0daK1+D4LiQW3B8DcO0HcZ8FQq25zKOYUQ0MFks9lFzSC5I/68pOkq4DVJe2tJ 1tdmz6uOMSPVU0xpL2moNAEhxLvKFawKXHx5iLIp1IRLxeUIkLauKPCP+T8CXBYqoaC7 918YqXHzF5dGMHfNzzLVN6WHXy4jrGH2EnD1Cz0s8A927TzuefFrVVJewl09jr5N2mnp ByYQ== X-Gm-Message-State: ALoCoQnGCcu4XrlablGPM7CShsUIR0LVoTy+faeABb6cS5HysvicKe4VT+S17ekL1b/lrhIdEE/F X-Received: by 10.182.236.66 with SMTP id us2mr18945144obc.45.1445821357806; Sun, 25 Oct 2015 18:02:37 -0700 (PDT) From: Bart Schaefer Message-Id: <151025180235.ZM30558@torch.brasslantern.com> Date: Sun, 25 Oct 2015 18:02:35 -0700 In-Reply-To: <562D31C3.9030705@eastlink.ca> Comments: In reply to Ray Andrews "greps pipes and eval bad patterns" (Oct 25, 12:47pm) References: <562D31C3.9030705@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: greps pipes and eval bad patterns MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 25, 12:47pm, Ray Andrews wrote: } } test1 () } { } gstring=" | grep \[01;34m " } tree --du -haC | grep -Ev "^[^\[]{$levels}\[*" "$gstring" } } One doesn't normally build up a pipeline that way, but if you must do so, you're on the right track with "eval" -- you just haven't applied enough quoting. "eval" is going to re-parse everything, so you need to quote everyhing to the same depth: eval 'tree --du -haC | grep -Ev "^[^\[]{$levels}\[*"' "$gstring" The single quotes (before tree and after the levels pattern) keep the first pipeline (and importantly the double-quotes that are around the grep pattern) from being interpreted until eval does so. The use of the parameter for $gstring has the same effect. You might be able to see this better if you assign everything to variables before eval-ing, e.g. test1 () { gstring="| grep \[01;34m " glevels='| grep -Ev "^[^\[]{$levels}\[*"' tree="tree --du -haC" eval "$tree" $glevels" "$gstring" }