From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: while {some command does not exit = 1)
Date: Sun, 2 Jun 2013 22:05:31 -0700 [thread overview]
Message-ID: <CAH+w=7Zh+15Qgqg8=AK+kRcchxnQ7n7XYgsMbLEw-mxEuwcSUg@mail.gmail.com> (raw)
In-Reply-To: <CADjGqHuB9krtxv5kVRR0xp04SWKBSXQ5rULCVavceri2+2Kc9g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
On Sun, Jun 2, 2013 at 9:24 PM, TJ Luoma <luomat@gmail.com> 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.
prev parent reply other threads:[~2013-06-03 5:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-03 4:24 TJ Luoma
2013-06-03 5:05 ` Bart Schaefer [this message]
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='CAH+w=7Zh+15Qgqg8=AK+kRcchxnQ7n7XYgsMbLEw-mxEuwcSUg@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--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).