NetBSD-Bugs archive

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

Re: bin/57438: set -o with unknown option aborts a script



The following reply was made to PR bin/57438; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/57438: set -o with unknown option aborts a script
Date: Sat, 27 May 2023 12:06:25 +0700

     Date:        Fri, 26 May 2023 22:20:02 +0000 (UTC)
     From:        Valery Ushakov <uwe%stderr.spb.ru@localhost>
     Message-ID:  <20230526222002.115061A9239%mollari.NetBSD.org@localhost>
 
   |  What is the kosher way to set e.g. pipefail that is not supported in
   |  older shell versions?
   |  
   |     (set -o pipefail) && set -o pipefail
   |  ?
 
 Yes, though redirect stderr to avoid the semi-expected
 error message, and I always suggest using "if" rather than
 "&&" when that is what you mean:
 
 	if (set -o pipefail) 2>/dev/null; then set -o pipefail; fi
 
 Things get trickier if you want to use some syntax that only
 some shells support, as that gets parsed, even if not executed,
 but that is not a problem in cases like this.
 
 kre
 


Home | Main Index | Thread Index | Old Index