From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15240 invoked by alias); 25 Oct 2015 20:17:24 -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: 20819 Received: (qmail 28828 invoked from network); 25 Oct 2015 20:17:21 -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,T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=jYPjbpmesg/B6vDH3dBD8Q==:117 a=jYPjbpmesg/B6vDH3dBD8Q==:17 a=IkcTkHD0fZMA:10 a=6U0-3YfxEicAD2nydqMA:9 a=QEXdDO2ut3YA:10 Message-id: <562D31C3.9030705@eastlink.ca> Date: Sun, 25 Oct 2015 12:47:15 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: Zsh Users Subject: greps pipes and eval bad patterns Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit 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.)