Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16745

Re: Dashes in function names: Undocumented?

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: Dashes in function names: Undocumented?
Date 2020-08-12 11:05 -0400
Message-ID <mailman.1737.1597244760.2739.bug-bash@gnu.org> (permalink)
References <CAL20dLDNniiOycTe-j6t0ynS+9FG32UgDGJbn+iDEMG7Ls_==Q@mail.gmail.com> <f53f8a84-ac66-6d61-7066-01c14e8f2ce4@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 8/12/20 10:51 AM, Matthew Persico wrote:
> I put a bug report into an emacs group because the bash syntax highlighter
> failed to recognize functions whose names have dashes in them.
> 
> The maintainer came back with this:
> 
> I can reproduce this behaviour, but is it really a bug? Aren't the
> names with '-' invalid?
> The Bash Reference Manual says:
> name
>  A word consisting solely of letters, numbers, and underscores, and
>  beginning with a letter or underscore. Names are used as shell
>  variable and function names. Also referred to as an identifier.
> https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html
> 
> I looked at the manual and I didn't see positive or negative
> acknowledgement that dashes can be used in function names. But it does work.
> 
> Update to manual?

The bash-20191127 snapshot updated the manpage documentation for a
function definition (to align with reality). It is now defined as:

function fname [()] compound-command [redirection]

and includes the description:

When in posix mode, fname must be a valid shell name and may not be the
name of one of the POSIX special builtins. In default mode, a function
name can be any unquoted shell word that does not contain $.

For context:

word  -  A sequence of characters considered as a single unit by the
shell. Also known as a token.

name  -  A word consisting only of alphanumeric characters and
underscores, and beginning with an alphabetic character or an
underscore. Also referred to as an identifier.


> name
>  A word consisting solely of letters, numbers, and underscores, and
>  beginning with a letter or underscore. Names are used as shell
>  variables. Also referred to as an identifier.
> 
> function name
>  A word consisting solely of letters, numbers, underscores, dashes, and
>  beginning with a letter or underscore. Function names are used to label
> shell
>  functions.
> 


-- 
Eli Schwartz
Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Dashes in function names: Undocumented? Eli Schwartz <eschwartz@archlinux.org> - 2020-08-12 11:05 -0400

csiph-web