From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 2 18:40:23 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org 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 1AA7B16A5D9 for ; Thu, 2 Nov 2006 18:40:23 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1015143D8E for ; Thu, 2 Nov 2006 18:40:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kA2IeH4X071425 for ; Thu, 2 Nov 2006 18:40:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kA2IeH9V071424; Thu, 2 Nov 2006 18:40:17 GMT (envelope-from gnats) Resent-Date: Thu, 2 Nov 2006 18:40:17 GMT Resent-Message-Id: <200611021840.kA2IeH9V071424@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, Ed Maste Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA29216A492 for ; Thu, 2 Nov 2006 18:31:12 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88F5043D55 for ; Thu, 2 Nov 2006 18:31:12 +0000 (GMT) (envelope-from emaste@FreeBSD.org) Received: from freefall.freebsd.org (emaste@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kA2IVCfN069785 for ; Thu, 2 Nov 2006 18:31:12 GMT (envelope-from emaste@freefall.freebsd.org) Received: (from emaste@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kA2IVCTB069784; Thu, 2 Nov 2006 18:31:12 GMT (envelope-from emaste) Message-Id: <200611021831.kA2IVCTB069784@freefall.freebsd.org> Date: Thu, 2 Nov 2006 18:31:12 GMT From: Ed Maste To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/105078: sh(1) aborts on invalid substitution in a not-taken if statement X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ed Maste List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2006 18:40:23 -0000 >Number: 105078 >Category: bin >Synopsis: sh(1) aborts on invalid substitution in a not-taken if statement >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Nov 02 18:40:17 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Ed Maste >Release: FreeBSD 6.0-STABLE i386 >Organization: FreeBSD >Environment: System: FreeBSD freefall.freebsd.org 6.0-STABLE FreeBSD 6.0-STABLE #0: Sat Dec 10 03:18:20 UTC 2005 kensmith@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386 >Description: It seems our sh(1) attempts to evaluate variable substitutions inside of an if statement even if the statement evaluates to false. I discovered this with a shell script that encapsulated some Linux sh-isms inside of a check based on uname -s, and our sh aborted on those statements. That shell script was using a substring of the form ${var:1:3}, but I've used an intentionally bogus substitution of ${} in the example below. For reference, I observed the same behaviour with NetBSD's sh. My Debian box produced no error. (I'm not sure what sh variant it has installed as /bin/sh.) Solaris 10 was also silent (thanks rwatson for checking). >How-To-Repeat: $ /bin/sh -c 'if false; then x=${}; fi' Syntax error: Bad substitution >Fix: >Release-Note: >Audit-Trail: >Unformatted: