From papowell@astart.com  Tue Aug  6 10:24:15 2002
Return-Path: <papowell@astart.com>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6A86037B400
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 Aug 2002 10:24:15 -0700 (PDT)
Received: from astart2.astart.com (adsl-63-200-201-186.dsl.sndg02.pacbell.net [63.200.201.186])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 019BB43E6A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 Aug 2002 10:24:14 -0700 (PDT)
	(envelope-from papowell@astart.com)
Received: from h110.private (h110.private [10.0.0.110])
	by astart2.astart.com (8.11.6/8.11.6) with ESMTP id g76HOBc37713
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 6 Aug 2002 10:24:12 -0700 (PDT)
	(envelope-from papowell@astart.com)
Received: (from papowell@localhost)
	by h110.private (8.11.6/8.11.6) id g76HOBc00728;
	Tue, 6 Aug 2002 10:24:11 -0700 (PDT)
	(envelope-from papowell)
Message-Id: <200208061724.g76HOBc00728@h110.private>
Date: Tue, 6 Aug 2002 10:24:11 -0700 (PDT)
From: Patrick Powell <papowell@astart.com>
Reply-To: Patrick Powell <papowell@astart.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: FreeBSD-STABLE /bin/sh mishandles & && sequences 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41384
>Category:       bin
>Synopsis:       FreeBSD-STABLE /bin/sh mishandles & && sequences
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 06 10:30:01 PDT 2002
>Closed-Date:    Wed Sep 18 10:54:49 PDT 2002
>Last-Modified:  Wed Sep 18 10:54:49 PDT 2002
>Originator:     Patrick Powell
>Release:        FreeBSD 4.6-RELEASE i386
>Organization:
Astart Technologies
>Environment:
System:
   i386 FreeBSD-4.6 updated to 4.6-CURRENT using CVS

>Description:
The sequence command & && command is handled differently
in 4.5/4.6 and 4.6 after updating to 4.6 STABLE using CVS.
This breaks a whole slew of shell scripts, including the
startup script in the ports/database/mysqlXXX-server
port.

>How-To-Repeat:

The following script is used for examples:
  /tmp/a:
    #!/bin/sh
    date & && echo DONE

    FreeBSD 4.5
h110: {13} % sh -x /tmp/a
+ time
+
+ echo done
done

h114: {5} % uname -a
FreeBSD h114.private 4.6-RELEASE FreeBSD
4.6-RELEASE #0: Thu Jul 11 15:07:12 PDT 2002
papowell@h114.private:/usr/src/sys/compile/TEST  i386
h114: {6} % sh -x /tmp/a
+ time
+
+ echo done
done

    FreeBSD 4.6
h116: {102} % sh -x /tmp/a
/tmp/a: 1: Syntax error: "&&" unexpected

Note that:
    date & echo DONE

will execute correctly:
h116: {104} % sh
# date & echo done
done
# Tue Aug  6 10:19:15 PDT 2002

>Fix:

I suppose that you could violate the POSIX thing and allow
empty commands.  I suspect the problem has to do with the
Lexical Structure stuff:

   Lexical Structure
     The shell reads input in terms of lines from a file and breaks it up into
     words at whitespace (blanks and tabs), and at certain sequences of char-
     acters called ``operators'', which are special to the shell.  There are
     two types of operators: control operators and redirection operators
     (their meaning is discussed later).  The following is a list of valid
     operators:

     Control operators:
                   &     &&    (     )     \n
                   ;;    ;     |     ||

You might need to run a check over all the shell scripts that
are using & && sequences... especially in the ports tree.

Patrick
>Release-Note:
>Audit-Trail:

From: Denis Antrushin <adu@sparc.spb.su>
To: freebsd-gnats-submit@FreeBSD.org, papowell@astart.com
Cc:  
Subject: Re: bin/41384: FreeBSD-STABLE /bin/sh mishandles & && sequences
Date: Wed, 18 Sep 2002 18:43:09 +0400

 This change was introduced in src/bin/sh/parser.c ver 1.42
 (MAIN)/ver 1.29.2.7 (RELENG_4) as fix for PR bin/40389, which
 was about exactly opposite problem (so these two PRs are
 mutually exclusive :-) ).
 Also note that other shells do not allow such syntax
 
State-Changed-From-To: open->closed 
State-Changed-By: fanf 
State-Changed-When: Wed Sep 18 10:50:50 PDT 2002 
State-Changed-Why:  
This is an intentional change for POSIX conformance.  Broken scripts 
must be fixed. This has already been done for the mysql ports. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41384 
>Unformatted:
