From owner-freebsd-bugs Tue Aug 6 10:30:11 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A205637B400 for ; Tue, 6 Aug 2002 10:30:02 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC0AC43E70 for ; Tue, 6 Aug 2002 10:30:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g76HU1JU082493 for ; Tue, 6 Aug 2002 10:30:01 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g76HU1k7082492; Tue, 6 Aug 2002 10:30:01 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A86037B400 for ; 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 ; 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 ; 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 Reply-To: Patrick Powell To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/41384: FreeBSD-STABLE /bin/sh mishandles & && sequences Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 41384 >Category: bin >Synopsis: FreeBSD-STABLE /bin/sh mishandles & && sequences >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 06 10:30:01 PDT 2002 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message