Re: true/false vs zero/non zero exit status question.



On Apr 6, 3:24 pm, pk <p...@xxxxxxxxxx> wrote:
On Tuesday 7 April 2009 00:15, Chad wrote:

On a free unix shell site, I had written the following one line bash
script in order for me to automatically rejoin their chat line program
when I timed after after being idle for so long.

while party; do touch /dev/ttypj; sleep 1; done

The condition of the while loop is the exit status of "party"; if it returns
nonzero (ie, error), the while loop is interrupted.



Anyhow, one of the powers that be on that system suggested that I re-
write the code like the following..

while true; do party; touch `tty`; done

"true" is guaranteed to return zero (ie, success); so this while loop will
never exit.


Okay, maybe I'm being a tad bit dense here, but are you saying that if
I have something like 'while true', then the loop will continue to
execute, regardless if party returns a zero or non zero exit status?
.



Relevant Pages

  • Re: TRUE is 0 is FALSE
    ... TRUE can be either active low (near zero) or active high, ... If something succeeds it returns 0 as an exit code. ... commands and takes the "then" branch if the exit status is SUCCESS. ... "A while or until loop and an if then else branch are also provided whose ...
    (comp.unix.shell)
  • Re: true/false vs zero/non zero exit status question.
    ... "true" is guaranteed to return zero ... loop will never exit. ... returns a true exit status, the loop body (the command ...
    (comp.unix.shell)
  • Re: generic strncpy - off-by-one error
    ... > the disassembled CRIS version of your first while loop ... test count and exit if count is zero. ... Exit on zero and decrement count. ...
    (Linux-Kernel)
  • Re: true/false vs zero/non zero exit status question.
    ... when I timed after after being idle for so long. ... The condition of the while loop is the exit status of "party"; ...
    (comp.unix.shell)
  • Re: true/false vs zero/non zero exit status question.
    ... I have something like 'while true', then the loop will continue to ... regardless if party returns a zero or non zero exit status? ... Wouldn't the loop would terminate if the status returned by party ... It's only the exit status of the command in the while ...
    (comp.unix.shell)