Subject: bin/23817: sh allows empty LHS to short-circuit operators
To: None <>
From: None <>
List: netbsd-bugs
Date: 12/21/2003 01:38:58
>Number:         23817
>Category:       bin
>Synopsis:       sh allows empty LHS to short-circuit operators
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 21 06:54:00 UTC 2003
>Originator:     VaX#n8
>Release:        NetBSD 1.5.1


$ && echo hi

I just want to document this behavior first, before I try fixing things.
I think this should be a syntax error (it is in BASH).  This patch is
dependent on one I just sent in a few hours ago, but is simple.  I found
this error when I was trying to continue lines in an if conditional

After looking at the code, it's not surprising to me that ash's parser has
some dark corners.

--- sh.1~	Sun Dec 21 01:28:36 2003
+++ sh.1	Sun Dec 21 01:30:39 2003
@@ -581,6 +581,9 @@
 .Dq baz
 and nothing else.  This is not the way it works in C.
+Also, if you forget the left-hand side (for example when continuing lines but
+forgetting to use a backslash) it defaults to a true statement.  This behavior
+is not useful and should not be relied upon.
 .Ss Flow-Control Constructs -- if, while, for, case
 The syntax of the if command is
 .Bd -literal -offset indent