Subject: bin/35410: /bin/sh mishandles shell function definitions with function names that are not plain words
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <uwe@NetBSD.org>
List: netbsd-bugs
Date: 01/12/2007 02:30:00
>Number: 35410
>Category: bin
>Synopsis: /bin/sh mishandles shell function definitions with function names that are not plain words
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 12 02:30:00 +0000 2007
>Originator: Valeriy E. Ushakov
>Release: 4.99.
>Organization:
>Environment:
NetBSD bigmac 4.99.1 NetBSD 4.99.1 (BIGMAC) #2: Sat Sep 16 03:57:52 MSD 2006 uwe@bigmac:/export/netbsd/cvs/src/sys/arch/macppc/compile/BIGMAC macppc
>Description:
Shell doesn't correctly handle "funny" function names.
If shell function defintion has the function name quoted
(either with single or double quotes), the function will have
incorrect name:
$ "foo"() { echo foo; }
$ hash -v | grep function | vis -o
function \210foo() { echo foo; }
where \210 is CTLQUOTEMARK. ksh handles quoting and defines function
named 'foo' (without the quotes).
Similar leakage of itnernal parser data happens if the name
*looks* like a variable reference:
$ $bar () { echo bar; }
$ hash -v | grep function | vis -o
function \202\001bar=() { echo bar; }
ksh correctly complains that $bar is not a valid function name.
etc...
>How-To-Repeat:
See above
>Fix: