Groups | Search | Server Info | Keyboard shortcuts | Login | Register


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

Re: set -e again

Path csiph.com!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From Crystal Kolipe <kolipe.c@exoticsilicon.com>
Newsgroups muc.lists.netbsd.tech.userlevel
Subject Re: set -e again
Date Wed, 14 Jan 2026 13:46:16 +0000
Organization Newsgate at muc.de e.V.
Sender tech-userlevel-owner@NetBSD.org
Approved news-admin@muc.de
Distribution world
Message-ID <aWeeKG8ziRu40n77@exoticsilicon.com> (permalink)
References <> <202601141241.HAA04556@Stone.Rodents-Montreal.ORG>
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="89706"; mail-complaints-to="news-admin@muc.de"
Authentication-Results mail.netbsd.org (amavisd-new); dkim=pass header.d=exoticsilicon.com
DKIM-Signature v=1; a=ed25519-sha256; c=simple/simple; s=key_0000; x=1768419976; bh=NhALp3Jp1u+wM1EIgqiYI9WioSVYViHpyk08rxlsOD8=; h=subject:cc:to:from:date; d=exoticsilicon.com; b=qGpsHg3GBcwij4HXCcDt iaJdpHUjjMbjVHh2qKuLBNhCcn+R/FBZD7N5fNxVPuKZ4O8b6Ckqb6suZMjg0fETAg==
Content-Disposition inline
In-Reply-To <202601141241.HAA04556@Stone.Rodents-Montreal.ORG>
Precedence bulk
X-Newsgate-Id f02c70b8849f+
X-No-Archive Yes
Xref csiph.com muc.lists.netbsd.tech.userlevel:11710

Show key headers only | View raw


On Wed, Jan 14, 2026 at 07:41:41AM -0500, Mouse wrote:
> >> [...set -e vs shell functions...]
> 
> > Does this achieve what you want?
> 
> > #!/bin/sh
> > set -e
> > f() {
> > 	echo foo
> > 	false
> > 	echo bar
> > }
> > f
> > [ $? ] || echo baz
> > echo buzz
> 
> I'm not the original poster, but it does not achieve what I would
> expect, which is
> 
> foo
> baz
> buzz
> 
> That is, I would expect/want -e to cause the function to return showing
> failure.  Instead, it either does nothing or takes down the whole
> shell.

Ah, OK, the way I understood the OP was that 'false' taking down the whole
script was the desired/expected behaviour, but that that was not happening in
the second example with the conditional testing the exit staus of f().

--
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 | NextPrevious in thread | Next 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