Date: 29 Aug 2003 17:27:57 -0000 From: Paul Jarc <prj@po.cwru.edu> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Paul Jarc <prj@po.cwru.edu> Subject: bin/56147: FreeBSD/NetBSD /bin/sh mishandles positional parameters in "case" Message-ID: <20030829172757.25054.qmail@mail.webmonster.de> Resent-Message-ID: <200308291730.h7THUG9Y046669@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 56147 >Category: bin >Synopsis: FreeBSD/NetBSD /bin/sh mishandles positional parameters in "case" >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 Aug 29 10:30:16 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Paul Jarc >Release: FreeBSD 4.8-STABLE i386 >Organization: >Environment: System: FreeBSD datasink.webmonster.de 4.8-STABLE FreeBSD 4.8-STABLE #5: Wed Aug 6 10:27:33 CEST 2003 root@datasink.webmonster.de:/m/ad0s1e/build/obj/m/ad0s1e/build/src/sys/DATASINKv2 i386 >Description: In /bin/sh "case" patterns, wildcards are supposed to be interpreted as literal characters if they are quoted or are the result of an expansion. However, if they appear in the expansion of a positional parameter, they are interpreted as wildcards. This can cause scripts to fail silently and mysteriously. >How-To-Repeat: $ sh -c 'set "*"; case x in "$1") echo oops;; esac' oops >Fix: As a workaround, you can assign the value of the positional parameter to a named parameter, and expand that named parameter in the "case" pattern: $ sh -c 'set "*"; v=$1; case x in "$v") echo oops;; esac' >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030829172757.25054.qmail>