Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > muc.lists.netbsd.tech.userlevel > #11704

set -e again

Path csiph.com!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From David Holland <dholland-tech@netbsd.org>
Newsgroups muc.lists.netbsd.tech.userlevel
Subject set -e again
Date Wed, 14 Jan 2026 01:18:47 +0000
Organization Newsgate at muc.de e.V.
Sender tech-userlevel-owner@NetBSD.org
Approved news-admin@muc.de
Distribution world
Message-ID <aWbu963HcQMeCm2M@netbsd.org> (permalink)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="18411"; mail-complaints-to="news-admin@muc.de"
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1768353530; bh=4VTAMQ+IhW2KYHv2SczqUuzhe3BuGSkWHniOD5LmuoA=; h=Date:From:To:Subject:List-Id:List-Unsubscribe; b=BPvrIW8cobhJ++MW3Dq0/iLDU2QBbl4tvbphi2CGoC2wSr5OEeddXoFf3QvBZkT7L iu+PSA7xVUSdkREC+wLGKVGSQDbkhx6ozsfPKsM1RMNraJtvc3n8gooejm9qGRM9M1 b1rJ/Sb+VLpwIuj/7D4leKuP1KDBktBdwmG+vVsk=
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1768353527; bh=4VTAMQ+IhW2KYHv2SczqUuzhe3BuGSkWHniOD5LmuoA=; h=Date:From:To:Subject; b=G5zFQMZJDtm/ZvI6Z6xSh+JsLmGD5NE8PulM06UdOqLSg2OkBRJG1zzHzYTosD4Ei c47QVd//8Mkyv+Nmu57UTgWKmEzgym4PjkgTprhJkLo9HhTP2dtAWLh9bp7MSb1peU CtkqzIn6HfJvL5X1bBIlY2VDnKCPdQNATvwA9kmc=
Content-Disposition inline
Precedence bulk
X-Newsgate-Id f02c70b8849f+
X-No-Archive Yes
Xref csiph.com muc.lists.netbsd.tech.userlevel:11704

Show key headers only | View raw


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

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de

Back to muc.lists.netbsd.tech.userlevel | Previous | NextNext in thread | Find similar


Thread

set -e again David Holland <dholland-tech@netbsd.org> - 2026-01-14 01:18 +0000
  Re: set -e again "Greg A. Woods" <woods@planix.ca> - 2026-01-13 18:14 -0800
  Re: set -e again Mouse <mouse@Rodents-Montreal.ORG> - 2026-01-13 21:30 -0500
  Re: set -e again Crystal Kolipe <kolipe.c@exoticsilicon.com> - 2026-01-14 10:28 +0000
    Re: set -e again Mouse <mouse@Rodents-Montreal.ORG> - 2026-01-14 07:41 -0500
      Re: set -e again Crystal Kolipe <kolipe.c@exoticsilicon.com> - 2026-01-14 13:46 +0000
    Re: set -e again Robert Elz <kre@munnari.OZ.AU> - 2026-01-14 21:22 +0700
  Re: set -e again RVP <rvp@SDF.ORG> - 2026-01-14 13:39 +0000
  Re: set -e again Robert Elz <kre@munnari.OZ.AU> - 2026-01-14 21:09 +0700

csiph-web