On Thursday, June 28, 2012 02:37:17 PM Rainer Blome wrote: > The implementation of "set -e" does not respect "lexical nesting". > This can be very surprising.
None of the "set" options do, nor does the ERR trap. That would make this the exception. Here's a workaround (untested). sete() { [[ $- == *e* ]] && return 1 trap "$(</dev/stdin)" RETURN } <<EOF if [[ $FUNCNAME != \$FUNCNAME ]]; then set +e trap - RETURN else set -e fi EOF This will "set -e" in only the scope of the caller. It gets a bit more complicated if you want to use this RETURN feature more extensively and preserve other possible RETURN traps, but most people won't have to worry about that. -- Dan Douglas
signature.asc
Description: This is a digitally signed message part.