Sime makelike wrapper scripts support

Eli Schwartz eschwartz at archlinux.org
Mon Jan 13 17:22:30 UTC 2020


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,
you still might need to care about systems where /bin/sh is a symlink to
bash.

> 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.

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'm actually a fan of `set -e` (and even more `set -u`!) but my shell
> scripts don't compute (much - if any) - and the to-be-ignored error
> cases (read: called programs/scripts) can be counted with the fingers
> of one hand;-)

That's the best time to use set -e, yeah.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1601 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20200113/962e0d2f/attachment.asc>


More information about the busybox mailing list