Date: Tue, 6 Aug 2002 10:24:11 -0700 (PDT) From: Patrick Powell <papowell@astart.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/41384: FreeBSD-STABLE /bin/sh mishandles & && sequences Message-ID: <200208061724.g76HOBc00728@h110.private>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208061724.g76HOBc00728>