[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dashes in function names: Undocumented?
From: |
Eli Schwartz |
Subject: |
Re: Dashes in function names: Undocumented? |
Date: |
Wed, 12 Aug 2020 11:05:40 -0400 |
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
signature.asc
Description: OpenPGP digital signature