Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

functions can be created with dotted name but not removed

0 views
Skip to first unread message

Michael O'Donnell

unread,
Dec 4, 2009, 10:26:28 AM12/4/09
to bug-...@gnu.org, ba...@packages.debian.org, Michael O'Donnell

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall
uname output: Linux e521 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 4.0
Patch Level: 28
Release Status: release

Description:

A bash function with a dot in its name can be created and used with no
problems but cannot be removed - the "unset" command chokes on the name.


Repeat-By:

This sequence yields the expected results:

function f() { echo $FUNCNAME ; }
f
unset f

...while this sequence fails during the unset phase with the complaint
that the name is not a valid identifier:

function f.dot() { echo $FUNCNAME ; }
f.dot
unset f.dot

Michael O'Donnell

unread,
Dec 4, 2009, 10:25:53 AM12/4/09
to bug-...@gnu.org, ba...@packages.debian.org, Michael O'Donnell

pk

unread,
Dec 4, 2009, 5:10:40 PM12/4/09
to
Michael O'Donnell wrote:

> A bash function with a dot in its name can be created and used with no
> problems but cannot be removed - the "unset" command chokes on the name.
>
>
> Repeat-By:
>
> This sequence yields the expected results:
>
> function f() { echo $FUNCNAME ; }
> f
> unset f
>
> ...while this sequence fails during the unset phase with the complaint
> that the name is not a valid identifier:
>
> function f.dot() { echo $FUNCNAME ; }
> f.dot
> unset f.dot

Try

unset -f f.dot

DennisW

unread,
Dec 4, 2009, 6:21:33 PM12/4/09
to

I can confirm that this behavior is also present in 3.2.49(23)-release
and 4.0.33(1)-release.

Chet Ramey

unread,
Dec 4, 2009, 11:55:11 PM12/4/09
to Michael O'Donnell, bug-...@gnu.org, chet....@case.edu
Michael O'Donnell wrote:

> Bash Version: 4.0
> Patch Level: 28
> Release Status: release
>
> Description:
>
> A bash function with a dot in its name can be created and used with no
> problems but cannot be removed - the "unset" command chokes on the name.

It's true -- the shell allows you to define a function with an invalid
name containing a dot (in retrospect, probably not the wisest choice).
Since `unset' without options assumes it is unsetting a variable, and
bash doesn't allow you to create a variable whose name contains a dot,
you need to tell unset you're removing a function: `unset -f f.dot'.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


0 new messages