Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11539
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | idallen@home.idallen.ca |
| Newsgroups | gnu.bash.bug |
| Subject | local keyword hides return code of command substitution |
| Date | Tue, 22 Sep 2015 10:19:56 -0400 (EDT) |
| Lines | 43 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1598.1442934969.19560.bug-bash@gnu.org> (permalink) |
| NNTP-Posting-Host | lists.gnu.org |
| X-Trace | usenet.stanford.edu 1442934970 7247 208.118.235.17 (22 Sep 2015 15:16:10 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org,bash@packages.debian.org |
| Envelope-to | bug-bash@gnu.org |
| X-Sender-Id | totalchoicehosting|x-authuser|idallena |
| X-Sender-Id | totalchoicehosting|x-authuser|idallena |
| X-MC-Relay | Good |
| X-MailChannels-SenderId | totalchoicehosting|x-authuser|idallena |
| X-MailChannels-Auth-Id | totalchoicehosting |
| X-MC-Loop-Signature | 1442931600246:1550717778 |
| X-MC-Ingress-Time | 1442931600246 |
| X-AuthUser | idallena |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] |
| X-Received-From | 50.61.143.6 |
| X-Mailman-Approved-At | Tue, 22 Sep 2015 11:16:07 -0400 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.14 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:11539 |
Show key headers only | View raw
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-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall
uname output: Linux idallen-oak 3.19.0-28-generic #30-Ubuntu SMP Mon Aug 31 15:52:51 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3
Patch Level: 30
Release Status: release
Description:
Adding a "local" keyword to a variable assignment hides the
return code of a command substitution. Same problem in both
bash and dash shells.
The keyword may be operating as described in the man page,
but it is highly non-intuitive that adding it would do this.
The work-around is to use "local" to declare the variable first,
then do the command substitution assignment on another line and
check the return code there.
If the behaviour of "local" can't be changed, perhaps the man
page could warn about this?
Repeat-By:
Run this:
#!/bin/bash -u
# Using "local" keyword hides return code of command substitution.
# Same problem in both bash and dash shells.
# -Ian! D. Allen - idallen@idallen.ca - www.idallen.com
Myfunc () {
foo=$( false )
echo "return code should be 1: $?"
local bar=$( false )
echo "return code should be 1: $?"
}
Myfunc
Back to gnu.bash.bug | Previous | Next | Find similar
local keyword hides return code of command substitution idallen@home.idallen.ca - 2015-09-22 10:19 -0400
csiph-web