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.