Sime makelike wrapper scripts support

Bernd Petrovitsch bernd at petrovitsch.priv.at
Mon Jan 13 17:34:19 UTC 2020


On 2020-01-13 17:22, Eli Schwartz wrote:
> On 1/13/20 12:09 PM, Bernd Petrovitsch wrote:
>>> I'm not the one who initially proposed using -e ;) I'm not a fan of -e
>>> in the first place: http://mywiki.wooledge.org/BashFAQ/105
> [...]
>> Nice but most the examples don't apply in my world (and I'm
>> almost always using just /bin/dash anyways).
> 
> But do you write scripts with #!/bin/sh or #!/bin/dash? If the former,

The latter (of course - and in the Makefiles is SHELL=/bin/dash too;-)
- I'm living in the Fedora/RedHat and the Ubuntu/Debian worlds so I
know more of the differences than is pleasant;-)

[...]
>> Oh, and the "if" example at the start is blatantly wrong: compare
>> the output of
>> bash -ec 'if [ -d /foo ]; then echo true; else echo false; fi'; echo $?
>> with
>> bash -ec 'if [ -d / ]; then echo true; else echo false; fi'; echo $?
> 
> I'm not sure I understand what is supposed to be wrong here? [ -d /foo ]
> returns false, but wrapped in an if block, it suppresses early exits due
> to set -e. Exactly as the wiki page says.

Ooops, than I misunderstood it - sry for the noise.

> The point it is underlining, is that "fail when a command fails" is not
> actually that simple, it changes behavior depending on which shell you
> run and what shell syntax the command is wrapped in.

I consider/understand/parse/read the shells "if" not as command in the
sense of "ls"- similar to e.g. "while ...; do ... done", "for ... ; do
... done" and/or "case ... esac" ....

As for the FAQ: I wouldn't write "the implementors decided" because
IMHO at that time the implementor didn't really think and design the
language and features but added features more or less "useful" on
the fly.
And when someone realized that it was pretty convoluted and
too much special-cased, it was way too late because lots of
already existing scripts would have been broken.

MfG,
	Bernd
-- 
"I dislike type abstraction if it has no real reason. And saving
on typing is not a good reason - if your typing speed is the main
issue when you're coding, you're doing something seriously wrong."
     - Linus Torvalds


More information about the busybox mailing list