bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function names which contain a 'dash' character


From: Stephane Chazelas
Subject: Re: function names which contain a 'dash' character
Date: Thu, 8 May 2008 11:40:08 +0100
User-agent: Mutt/1.5.16 (2007-09-19)

On Wed, May 07, 2008 at 05:50:59PM -0400, Chet Ramey wrote:
> Poor Yorick wrote:
>> ksh refuses to define functions which contain a dash ("-") in the name.  
>> The
>> Bash manual also defines 'name' as consisting solely of letters, numbers, 
>> and
>> underscores.  So shouldn't bash refuse to create functions which contain a 
>> dash
>> in the name?
>
> When in posix mode, bash does so refuse.  In default (non-posix) mode, it
> is more liberal.
[...]

Note that bash didn't have to. POSIX allows a shell to accept
any character in a function name, but it says one shouldn't use
those in a POSIX script, which is different.

IMO, given that they share the same namespace as other commands,
I don't see why they should be more restricted than file paths
(any character but NUL and must not be empty). Or even, given
that they are an argument to a single command, they could be
empty.

zsh allows any character, even NUL and even the empty string:

$ ''() echo $@
$ "" foo
foo

So do rc and es (not the NULs, though).

-- 
Stéphane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]