Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11545
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: local keyword hides return code of command substitution |
| Date | 2015-09-22 11:45 -0400 |
| Message-ID | <mailman.1605.1442936766.19560.bug-bash@gnu.org> (permalink) |
| References | <20150922141956.9E7ED81A59@idallen-oak.home.idallen.ca> |
On Tue, Sep 22, 2015 at 10:19:56AM -0400, idallen@home.idallen.ca wrote:
> 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.
Yes, this is how it works. If you care about the return value of a
command used to initialize a local variable, you have to write it in
two steps:
foo() {
local foo
foo=$(bar) || return
}
http://mywiki.wooledge.org/BashPitfalls has this and many more.
Back to gnu.bash.bug | Previous | Next | Find similar
Re: local keyword hides return code of command substitution Greg Wooledge <wooledg@eeg.ccf.org> - 2015-09-22 11:45 -0400
csiph-web