From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 3 17:40:17 2003 Return-Path: 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 B9F3616A4B3 for ; Fri, 3 Oct 2003 17:40:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2B2A43FFB for ; Fri, 3 Oct 2003 17:40:14 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h940eEFY066108 for ; Fri, 3 Oct 2003 17:40:14 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h940eEnq066107; Fri, 3 Oct 2003 17:40:14 -0700 (PDT) (envelope-from gnats) Resent-Date: Fri, 3 Oct 2003 17:40:14 -0700 (PDT) Resent-Message-Id: <200310040040.h940eEnq066107@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, Mark Valentine Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13EA716A4B3 for ; Fri, 3 Oct 2003 17:37:20 -0700 (PDT) Received: from colossus.systems.pipex.net (colossus.systems.pipex.net [62.241.160.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id C359143FB1 for ; Fri, 3 Oct 2003 17:37:18 -0700 (PDT) (envelope-from mark@thuvia.org) Received: from dotar.thuvia.org (81-86-228-29.dsl.pipex.com [81.86.228.29]) by colossus.systems.pipex.net (Postfix) with ESMTP id C482A16000103 for ; Sat, 4 Oct 2003 01:37:16 +0100 (BST) Received: from dotar.thuvia.org (localhost [127.0.0.1]) by dotar.thuvia.org (8.12.9/8.12.9) with ESMTP id h940bGPA077985 for ; Sat, 4 Oct 2003 01:37:16 +0100 (BST) (envelope-from mark@dotar.thuvia.org) Received: (from mark@localhost) by dotar.thuvia.org (8.12.9/8.12.9/Submit) id h940bGPL077984; Sat, 4 Oct 2003 01:37:16 +0100 (BST) (envelope-from mark) Message-Id: <200310040037.h940bGPL077984@dotar.thuvia.org> Date: Sat, 4 Oct 2003 01:37:16 +0100 (BST) From: Mark Valentine To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/57554: sh(1) incorrect handling of quoted parameter expansion X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Mark Valentine List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Oct 2003 00:40:17 -0000 >Number: 57554 >Category: bin >Synopsis: sh(1) incorrect handling of quoted parameter expansion >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 03 17:40:14 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Mark Valentine >Release: FreeBSD 4.8-STABLE i386 >Organization: >Environment: System: FreeBSD dotar.thuvia.org 4.8-STABLE FreeBSD 4.8-STABLE #6: Wed Jun 11 15:04:41 BST 2003 root@dotar.thuvia.org:/usr/obj/usr/src/sys/DOTAR i386 >Description: sh(1) incorrectly quotes the pattern word in parameter expansions involving prefix/suffix removal when the whole expansion is enclosed in double quotes: $ foo='\{foo' $ echo ${foo#\{} \{foo # correct (1) - pattern is { $ echo ${foo#"\{"} foo # correct (2) - pattern is \{ $ echo "${foo#\{}" foo # WRONG - should be same as (1) IEEE Std 1003.1-2001 states that "Enclosing the full parameter expansion string in double-quotes shall not cause the [...] pattern characters to be quoted, whereas quoting characters within the braces shall have this effect." NOTE: there seems to be a related problem with our handling of ${foo#{} - bash and ksh seem to expect a further matching } - but I haven't managed to figure out chapter and verse on that one! I initially came across this bug in the context of (foo='{foo' and "${foo#\{}" doing the wrong thing (real life scenario: FreeBSD- hosted NetBSD build falls over in distrib/utils/sysinst/msg_xlat.sh), but the above example is a clearer illustration of the part I did manage to find chapter and verse on... >How-To-Repeat: >Fix: NetBSD's sh(1) handles this correctly, if the code change can be identified... (NOTE: possibly look at their parser.c rev 1.51 and 1.52; my brain's shut down for the day.) >Release-Note: >Audit-Trail: >Unformatted: