tech-userlevel archive

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

Re: set -e again



    Date:        Wed, 14 Jan 2026 01:18:47 +0000
    From:        David Holland <dholland-tech%netbsd.org@localhost>
    Message-ID:  <aWbu963HcQMeCm2M%netbsd.org@localhost>

  | I discovered the following today.

I would have expected you to be aware of all this already.

  | This seems wrong - the exit status of the f is guarded, but the false
  | is not.

Doesn't matter, it is executing in a place to the left of a || hence
the setting of -e is ignored.

  | Is this intended, and is there a way to get the user's intended
  | behavior of exit on unchecked failure back?

It is, and no, there isn't.   Use of -e in anything other than a list of
simple commands, one after the other, almost always runs into problems.
It was originally intended for (old style) makefile use, not for lazy
script writers.

Simply explicitly test every command's status which matters, explicitly,
and everything will work as you intend.   Don't use -e, almost ever.
(And -u isn't a lot better, but at least that one is more predictable).

kre



Home | Main Index | Thread Index | Old Index