NetBSD-Bugs archive

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

Re: bin/48489 (sh(1) allows trailing && and ||)

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

From: Robert Elz <kre%munnari.OZ.AU@localhost>
Subject: Re: bin/48489 (sh(1) allows trailing && and ||)
Date: Wed, 24 Feb 2016 23:08:28 +0700

  | sh accepts trailing && or ||, which ought to be a syntax error.
 Yes, it should be, but does it really matter?
 Miwa Susumu's reading of the grammar in the reply in the PR
 was mistaken - it is certainly true that an && or || may be followed
 by a \n, but that (whether that appears or not) they must be followed by
 a pipeline, and that can't be empty.
 Now (since the past hour or so) our sh(1) documents this odd behaviour,
 describes it as useless (which it is) - but at least it should not
 be a surprise.
 sh also allows an empty command before && or || - which it also
 shouldn't, but again, does anyone really care.  This one has been
 documented in sh(1) for ages.
 And yes, taking these two oddities together means that
 	sh -c '&&'
 does not generate any errors, and returns an exit code of 0.
 No-one should rely upon this, it is not portable, but it is also harmless,
 I think.
 If anyone really believes it is worth spending time on, I could look and
 see if I can adjust the parser to avoid this, but unless there is some
 good reason ("comply with the std" is not) to do it, I think there are
 other bugs, that actually affect rational operation, that I can better
 spend time on.
 Is the doc of this sufficient for this PR to be closed?

Home | Main Index | Thread Index | Old Index