[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: command substitution is stripping set -e from options
From: |
Christoph Gysin |
Subject: |
Re: command substitution is stripping set -e from options |
Date: |
Sat, 3 Oct 2015 11:35:11 +0300 |
> Chet can give the definitive answer, but my take is that it's a huge
> surprise to someone writing a function independent of the script, or
> using a function that was written independently of the script. If the
> function does not expect set -e to be in effect (which is not the default,
> and is not done in any sane environment, so why would anyone EXPECT it?)
> then it may have been written to work in a normal environment, and will
> fail in a set -e environment.
Yes, obviously you can't just source other bash files and assume they
work with set -e (or set -u for that matter). But if I do I still have
the option of consciously disabling said options with set +e.
> I have many examples of commands that surprisingly explode and set your
> house on fire when run in a set -e environment, but which work perfectly
> well in a regular environment. See http://mywiki.wooledge.org/BashFAQ/105
Thanks for that excellent resource!
Maybe I spent too much time with bash scripts, but I'm already aware
of all those corner cases. Yes they are not pretty, but for each of
them there is a simple workaround. Tools like shellcheck will even
warn you about some of them.
The behaviour I describe seems to fall in a different category though.
Switching to posix mode has all kinds of other side effects, so I
don't think that's a valid workaround.
And it seems that the code to inherit set -e is already there, just
not enabled by default. This seems to cause behaviour that is
counter-intuitive IMO.
Chris
- command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Chet Ramey, 2015/10/08
- Re: command substitution is stripping set -e from options, Eric Blake, 2015/10/08
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Greg Wooledge, 2015/10/08
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Greg Wooledge, 2015/10/08
- Re: command substitution is stripping set -e from options,
Christoph Gysin <=
- Re: command substitution is stripping set -e from options, Chet Ramey, 2015/10/08
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Chet Ramey, 2015/10/09
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Greg Wooledge, 2015/10/08
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/08
- Re: command substitution is stripping set -e from options, Chet Ramey, 2015/10/10
- Re: command substitution is stripping set -e from options, Christoph Gysin, 2015/10/13
- Re: command substitution is stripping set -e from options, Chet Ramey, 2015/10/15
- Re: command substitution is stripping set -e from options, Linda Walsh, 2015/10/15