[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: functions and set -e
From: |
Paul Jarc |
Subject: |
Re: functions and set -e |
Date: |
Wed, 30 Aug 2006 00:03:51 -0400 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux) |
Greg Schafer <gschafer@zip.com.au> wrote:
> #!/bin/sh
> set -e
>
> func () {
> false && echo false
> true && echo true
> false && echo false
> }
>
> func
>
> echo done
>
>
> It never echoes "done" because func() returns 1.
That's the correct behavior. The last "false" within the function
does not immediately cause bash to exit, since it is part of the "&&"
comound statement. But then the function call itself, which is a
simple command in its own right, has a nonzero exit status, so bash
exits at that point.
paul