bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDEA] more granular shell options to fix errexit


From: Ivan Pozdeev
Subject: [IDEA] more granular shell options to fix errexit
Date: Sat, 29 Dec 2018 07:23:57 +0300
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3

With the recent inherit_errexit , the Bash team seems to have finally bumped into a workable way to fix errexit which has been broken for decades (https://mywiki.wooledge.org/BashFAQ/105).

Instead of trying to invent a replacement shell option for that and hope to get it right on the first try (that errexit failed to), make granular options that would each change a single thing -- and see which of them pass the test of time.

The following suggested options aim to eliminate all cases that still exist, outlined on the above link, where an exit code of a command is swallowed/ignored.

* Do not unset `-e' inside a "checked command": only use the logic in the "The shell does not exit" clause when checking the exit code of the checked command, as a unit.

   (I would argue that this is the intended POSIX semantic in the first place but I guess I'm about 25 years late to the party.)
   Suggested option name: preserve_errexit

* If a command substitution fails, fail the containing command. Suggested name: cmdsubstfail

* Same for process substitution. Fail the command the same way as a pipeline with pipefail (and either only if pipefail is set, or imply pipefail). Suggested name: prsubstfail

(Probably the same for history expansion. I don't use it so have no opinion here.)

I don't have an opinion if they should be shell options or `shopt' options -- no differences to speak of in my book.

--
Regards,
Ivan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]