From owner-freebsd-bugs@FreeBSD.ORG Sun Jan 24 06:10:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9AE3B106568D for ; Sun, 24 Jan 2010 06:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CFCCE8FC15 for ; Sun, 24 Jan 2010 06:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o0O6A0cd047307 for ; Sun, 24 Jan 2010 06:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o0O6A0i8047306; Sun, 24 Jan 2010 06:10:00 GMT (envelope-from gnats) Resent-Date: Sun, 24 Jan 2010 06:10:00 GMT Resent-Message-Id: <201001240610.o0O6A0i8047306@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6521D106566C for ; Sun, 24 Jan 2010 06:02:27 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 532A68FC18 for ; Sun, 24 Jan 2010 06:02:27 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0O62RJU007725 for ; Sun, 24 Jan 2010 06:02:27 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o0O62REn007724; Sun, 24 Jan 2010 06:02:27 GMT (envelope-from nobody) Message-Id: <201001240602.o0O62REn007724@www.freebsd.org> Date: Sun, 24 Jan 2010 06:02:27 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/143142: [PATCH] Fix non-POSIX compliant multiline conditional in portsnap(1) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2010 06:10:02 -0000 >Number: 143142 >Category: misc >Synopsis: [PATCH] Fix non-POSIX compliant multiline conditional in portsnap(1) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jan 24 06:10:00 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 9-CURRENT >Organization: Ironport >Environment: [gcooper@optimus /usr/ports]$ uname -a FreeBSD optimus.zenmetsuhitotuyaneshita.net 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Thu Jan 7 17:03:57 PST 2010 root@optimus.zenmetsuhitotuyaneshita.net:/usr/obj/usr/src/sys/OPTIMUS amd64 >Description: Over a year ago, I submitted an email to determine why bash didn't function with portsnap because I tried updating my ports via my Mac, because at the time I didn't have a network connection in my apartment. bash is the system shell on Mac, and thus it failed to execute, like so: [gcooper@optimus /usr/ports]$ bash `which portsnap` /usr/sbin/portsnap: line 882: syntax error near unexpected token `newline' /usr/sbin/portsnap: line 882: ` if !' According to the bash folks (), multiline // inline conditionals aren't POSIX compliant. Thus, there are two issues with how portsnap is coded today. The attached patch takes care of those issues, and also swaps out `basename $0` for ${0##*/} (equivalent logic in Bourne shell). This has been tested on sh in -CURRENT and bash 4.x, and there isn't a regression with the affected logic paths when doing: portsnap fetch extract Additional blocks may or may not need to be tested. >How-To-Repeat: bash `which portsnap` >Fix: See attached patch. Patch attached with submission follows: Index: portsnap.sh =================================================================== --- portsnap.sh (revision 202909) +++ portsnap.sh (working copy) @@ -34,7 +34,7 @@ # --no-stats -- don't show progress statistics while fetching files usage() { cat <Release-Note: >Audit-Trail: >Unformatted: