tech-userlevel archive

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

set -e again




To: tech-userlevel%netbsd.org@localhost

Subject: set -e again

From: David Holland <dholland-tech%netbsd.org@localhost>

Date: Wed, 14 Jan 2026 01:18:47 +0000


I discovered the following today.

This:
   set -e
   f() {
       echo foo
       false
       echo bar
   }
   f

as one might expect, prints "foo" and exits.

However, this:
   set -e
   f() {
       echo foo
       false
       echo bar
   }
   f || echo baz
   echo buzz

prints "foo", "bar", "buzz", and continues. Furthermore, all the
shells I have in easy reach agree on it.

This seems wrong - the exit status of the f is guarded, but the false
is not. But also, the fact that everybody agrees makes me think it's
probably the agreed result of the last round of POSIX wrangling over
the -e definition some years back.

Is this intended, and is there a way to get the user's intended
behavior of exit on unchecked failure back? (E.g. is there a different
set to get functions to return on unchecked failure that might cover
this?)

-- 
David A. Holland
dholland%netbsd.org@localhost


Follow-Ups:

Re: set -e again
From: Robert Elz

Re: set -e again
From: Robert Elz

Re: set -e again
From: RVP

Re: set -e again
From: Crystal Kolipe

Re: set -e again
From: Mouse

Re: set -e again
From: Greg A. Woods




Prev by Date: udp and spec issues

Next by Date: Re: set -e again

Previous by Thread: udp and spec issues

Next by Thread: Re: set -e again

Indexes:

reverse Date

reverse Thread

Old Index



Home | Main Index | Thread Index | Old Index