Björn Augustsson wrote:

> Bash Version: 3.2
> Patch Level: 33
> Release Status: release
> 
> Description:
> 
>         The test case below is pretty self-explanatory.
>         The assignment in fun_bad() doesn't exit the shell,
>         despite the "set -e".
> 
>         This is the version in Fedora 8.
>         Also happens on
>         * Bash Version: 3.1 Patch Level: 17 (Ubuntu Dapper)
>         * Bash Version: 3.2 Patch Level: 0 (from ftp.gnu.org))
> 
> 
> Repeat-By:
> 
> -----------------------------8<-------------------------
> #!/bin/bash
> 
> set -e
> 
> fun_bad() {
>         local bah=$( false )
> }
> 
> fun_good() {
>         local bah
>         bah=$( false )
> }
> 
> echo "start"
> 
> fun_bad
> echo "FAIL"
> fun_good
> echo "(Does not get here.)"

This isn't a bug.

The `local' command returns success if the variable assignment succeeds,
which it does.  The command substitution doesn't affect its exit status.
This is how all builtins that affect variable attributes (declare/typeset,
export, readonly) should behave.

A line consisting of only assignment statements returns success unless
it contains a command substitution, in which case it returns the status
of the command substitution.  This is as Posix specifies.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    [EMAIL PROTECTED]    http://cnswww.cns.cwru.edu/~chet/


Reply via email to