[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC] Logically composable variant of errexit
From: |
Andreas Grünbacher |
Subject: |
[RFC] Logically composable variant of errexit |
Date: |
Thu, 9 Oct 2014 14:20:19 +0200 |
Hi all,
the errexit option can be very useful in simple scripts. This option
is being ignored in many contexts like lists and conditionals though.
I understand that this is "by design" and that errexit cannot be
"fixed" to behave more reasonably. Still, this makes bash a lot less
useful than it could be; working around this limitation is painful,
ugly, and leads to fragile code.
So, since we cannot "fix" errexit, can we maybe introduce another
option like "errfail" that behaves like errexit for simple commands,
but is also logically composable? Let me show what I mean with the
following pseudo-code:
set -o errfail
fail() {
false
echo 'oops!' >&2 # not reached
}
! fail
fail || :
if fail; then
:
fi
set -- `fail` # script fails here
echo 'oops!' >&2 # not reached
Having such an option would certainly make bash a lot more useful to me.
What do you guys think, could such an option be implemented with
reasonable effort?
Thanks,
Andreas
- [RFC] Logically composable variant of errexit,
Andreas Grünbacher <=