zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: while {some command does not exit = 1)
Date: Mon, 3 Jun 2013 00:24:35 -0400	[thread overview]
Message-ID: <CADjGqHuB9krtxv5kVRR0xp04SWKBSXQ5rULCVavceri2+2Kc9g@mail.gmail.com> (raw)

I keep thinking that there must be an easier way to do this, but I
can't figure out what it would be, and Google has not helped.

I'm trying to create a "while" loop which will keep going as long as
some command does not exit = 0

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

exit 0
# EOF

(where 'FOO' is some command I want to run)

What I keep thinking I ought to be able to do is something like this

while ((! drutil discinfo | fgrep -q 'Please insert a disc to get disc info.' ))
do

	FOO


done

I realize that "while (( ))" syntax is wrong, but I hope the idea is
clear. It appears that the | might be what is making this not work.

Is there an easier way to do this?

TjL


             reply	other threads:[~2013-06-03  4:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03  4:24 TJ Luoma [this message]
2013-06-03  5:05 ` Bart Schaefer

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=CADjGqHuB9krtxv5kVRR0xp04SWKBSXQ5rULCVavceri2+2Kc9g@mail.gmail.com \
    --to=luomat@gmail.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).