[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Return status of command substitution with $(...) "gets lost"
From: |
Chris F.A. Johnson |
Subject: |
Re: Return status of command substitution with $(...) "gets lost" |
Date: |
Thu, 4 Mar 2010 18:40:09 -0500 (EST) |
User-agent: |
Alpine 2.00 (LMD 1167 2008-08-23) |
On Thu, 4 Mar 2010, Ettelbrueck, Heiko wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
> -g -O2
> uname output: Linux wdfd00221495a 2.6.27.42-0.1-xen #1 SMP 2010-01-06
> 16:07:25 +0100 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> Bash Version: 4.1
> Patch Level: 0
> Release Status: release
>
> Description:
> There is a function which runs some external tool. Both the
> tool's output and its exit status are relevant for further
> execution of the bash script.
> -> The tool's is stored into a (new) local variable, which is
> then processed further.
> -> The tool's exit status is retrieved from the $? variable.
>
> Important detail: The local variable is declared and defined in
> the same step with "local VARNAME=$(do something)".
>
> Problem: The $? variable is always 0 after that statement.
The return status is that of the command, local.
--
Chris F.A. Johnson <http://cfajohnson.com>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
- Return status of command substitution with $(...) "gets lost", Ettelbrueck, Heiko, 2010/03/04
- Re: Return status of command substitution with $(...) "gets lost",
Chris F.A. Johnson <=
- Re: Return status of command substitution with $(...) "gets lost", Chet Ramey, 2010/03/04
- Re: Return status of command substitution with $(...) "gets lost", Marc Herbert, 2010/03/10
- Re: Return status of command substitution with $(...) "gets lost", Eric Blake, 2010/03/10
- Re: Return status of command substitution with $(...) "gets lost", Chet Ramey, 2010/03/10
- Message not available
- Re: Return status of command substitution with $(...) "gets lost", Chet Ramey, 2010/03/11
- Re: Return status of command substitution with $(...) "gets lost", Marc Herbert, 2010/03/11
- Re: Return status of command substitution with $(...) "gets lost", Eric Blake, 2010/03/11
- Re: Return status of command substitution with $(...) "gets lost", Chet Ramey, 2010/03/11