[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: set -e, but test return not honoured _conditionally_
From: |
Pierre Gaston |
Subject: |
Re: set -e, but test return not honoured _conditionally_ |
Date: |
Tue, 22 Feb 2011 15:46:26 +0200 |
On Fri, Feb 18, 2011 at 5:36 PM, Steffen Daode Nurpmeso <
sdaoden@googlemail.com> wrote:
>
> Configuration Information [Automatically generated, do not change]:
> Machine: i386
> OS: darwin10.0
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
> -DCONF_OSTYPE='darwin10.0' -DCONF_MACHTYPE='i386-apple-darwin10.0'
> -DCONF_VENDOR='apple' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I/SourceCache/bash/bash-80/bash
> -I/SourceCache/bash/bash-80/bash/include
> -I/SourceCache/bash/bash-80/bash/lib
> -I/SourceCache/bash/bash-80/bash/lib/intl
> -I/var/tmp/bash/bash-80~440/lib/intl -arch x86_64 -arch i386 -g -Os -pipe
> -no-cpp-precomp -mdynamic-no-pic -DM_UNIX -DSSH_SOURCE_BASHRC
> uname output: Darwin sherwood.local 10.6.0 Darwin Kernel Version 10.6.0:
> Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
> Machine Type: i386-apple-darwin10.0
>
> Bash Version: 3.2
> Patch Level: 48
> Release Status: release
>
> Description:
> I am not a sophisticated shell programmer, but i really think this
> time it's a shell fault.
> You may invoke the code snippet via 'script test1 test3' or so.
>
> #!/bin/sh
> set -e
>
> _t() {
> echo "Entry _t for $CURR"
> test "$PARAMS" != "${PARAMS/$CURR/}" && { return; }
> # Uncomment the next line and the script won't fail!
> #echo "Exit _t for $CURR"
> }
>
> PARAMS="$@"
>
> CURR='test1' _t
> CURR='test2' _t
> CURR='test3' _t
set -e only exits the shell when simple commands exit with errors, and not
for commands with && for instance.