bug-bash
[Top][All Lists]
Advanced

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

Re: [RFC] Logically composable variant of errexit


From: Andreas Grünbacher
Subject: Re: [RFC] Logically composable variant of errexit
Date: Fri, 10 Oct 2014 11:26:39 +0200

2014-10-10 3:29 GMT+02:00 Chet Ramey <chet.ramey@case.edu>:
> What does logically composable mean in this context?

I would like the hypothetical errfail option to:

 * Behave like errexit at the top level (outside of functions).

 * Be inherited by functions,  subshells, and command substitution.

 * Inside functions, it should trigger like errexit would outside of
   functions, no matter how the function is called.
   It should return instead of exiting, though.

With errexit, you get vastly different results from functions depending
on how the functions are called, for example,

   foo() {
      echo "foo: top"
      false
      echo "foo: bottom"
   }

   set -o errexit

   # bottom of foo reached:
    if foo; then
      echo "success"  # reached
   fi

   # bottom of foo not reached:
   foo

With errfail, "foo:bottom" and "success" would not be reached.

Command substitutions would continue to behave as basic commands
do with respect to control flow: inside functions, a failure would cause
the function to return; outside of functions, the script would exit.

Thanks,
Andreas



reply via email to

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