Subject: bug#21477: 24.4; Imenu - improper parse of shell function names

From: "Matthew Persico (BLOOMBERG/ 919 3RD A)" <[email-masked]>
Date: Wed, 12 Aug 2020 13:51:44 -0000

Interesting. I have function names with dashes all over and nothing complains. Not Bash 4.X, not shellcheck. If you ran that file in the post, it would not complain.

Now, you can't use dashes in variables. But functions work just fine.

I wonder if the bash manual needs an update?

From: [email-masked] At: 08/12/20 00:15:40To:  Matthew Persico (BLOOMBERG/ 919 3RD A ) 
Cc:  [email-masked]
Subject: Re: bug#21477: 24.4; Imenu - improper parse of shell function names

tags 21477 + moreinfo
thanks

"Matthew Persico (BLOOMBERG/ 731 LEX)" <[email-masked]> writes:

> 1) Create a file with this text:
> # -*- sh -*-
> this_is_parsed ()
> {
> echo 1
> }
>
> function this_is_also_parsed
> {
> echo 1
> }
>
> this-is-not-parsed ()
> {
> echo 1
> }
>
> function this-is-also-not-parsed
> {
> echo 1
> }
>
> 2) Load it into emacs that has imenu.
>
> 3) Look for functions in the imenu list. Only the ones with '_' show up. The 
ones with '-' do not.

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

Best regards,
Stefan Kangas