From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18069 invoked by alias); 3 Jun 2013 05:05:44 -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: 17819 Received: (qmail 19957 invoked from network); 3 Jun 2013 05:05:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=NeVfVLTlgF5BMjKIFzcx5Q/RSRkjCQWIefj+gvl7yqY=; b=Y2Af1EwZYpqqVfNwMVCVZuq8M8tkMrnZkr1hOZvcahd2Mc8xjUMSIY2ZYJBMYwO7Ub OBQZ8ontggbP93EXFM3tu3+zsBbktTk/aBD8tl3VV1MOg0qW0MV/b/2d6TMfcbOutBPP zrUsPq/hDBg5J6ZBvShDPN56Ivti4stjCCjewzeYf80PIrN5aCEJ77dKXjwDiYHCGjMf 19vHSKGmDrtQlVc2Ho5dhzLxDXWbIFoU0y0W4/+y8xCXnrGlSJax8dZ6rTtqMlxj0Ir2 rL00te8SiPrePQ7maS1+YkqbKfg6aDmrxx+XVJla3K6rz1ZjAwujgFH+fBPWtCrzYk3W 73aA== MIME-Version: 1.0 X-Received: by 10.152.29.169 with SMTP id l9mr10141797lah.31.1370235931635; Sun, 02 Jun 2013 22:05:31 -0700 (PDT) In-Reply-To: References: Date: Sun, 2 Jun 2013 22:05:31 -0700 Message-ID: Subject: Re: while {some command does not exit = 1) From: Bart Schaefer To: Zsh-Users List Content-Type: multipart/alternative; boundary=089e0158bfdef6c3a604de38e96c X-Gm-Message-State: ALoCoQldz0d1hk52RXijFRCXcofotjV6WifuJcIgciImqndGyHFmWV76VsT6eZ9jPv/HiWN8836P --089e0158bfdef6c3a604de38e96c Content-Type: text/plain; charset=ISO-8859-1 On Sun, Jun 2, 2013 at 9:24 PM, TJ Luoma wrote: > Here's what I have been doing: > > #!/bin/zsh -f > > EXIT=1 > > while [ "$EXIT" = "1" ] > do > > drutil discinfo | fgrep -q 'Please insert a disc to get disc info.' > > EXIT="$?" > > FOO > > done > It should work to just write while ! drutil discinfo | fgrep -q 'Please insert a disc to get disc info.' do FOO done Except that the $? value of the pipeline is going to be the exit status of fgrep, not of drutil. I suspect that's what you meant, so FOO runs only when a disc is present. You can make this clearer by writing it as while ! { drutil discinfo | fgrep -q 'Please insert a disc to get disc info.' } do FOO done Spaces around the "!" are important, especially if you're in a shell with history enabled. --089e0158bfdef6c3a604de38e96c--