* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
@ 2020-08-12 4:15 ` Stefan Kangas
2020-08-12 13:51 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Stefan Kangas @ 2020-08-12 4:15 UTC (permalink / raw)
To: Matthew Persico (BLOOMBERG/ 731 LEX); +Cc: 21477
tags 21477 + moreinfo
thanks
"Matthew Persico (BLOOMBERG/ 731 LEX)" <mpersico5@bloomberg.net> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
2020-08-12 4:15 ` Stefan Kangas
@ 2020-08-12 13:51 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-12 14:08 ` Stefan Kangas
2020-08-12 14:54 ` Andreas Schwab
2020-08-12 14:36 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
` (3 subsequent siblings)
5 siblings, 2 replies; 12+ messages in thread
From: Matthew Persico (BLOOMBERG/ 919 3RD A) @ 2020-08-12 13:51 UTC (permalink / raw)
To: stefan; +Cc: 21477
[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]
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: stefan@marxist.se At: 08/12/20 00:15:40To: Matthew Persico (BLOOMBERG/ 919 3RD A )
Cc: 21477@debbugs.gnu.org
Subject: Re: bug#21477: 24.4; Imenu - improper parse of shell function names
tags 21477 + moreinfo
thanks
"Matthew Persico (BLOOMBERG/ 731 LEX)" <mpersico5@bloomberg.net> 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
[-- Attachment #2: Type: text/html, Size: 3223 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2020-08-12 13:51 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-12 14:08 ` Stefan Kangas
2020-08-12 14:54 ` Andreas Schwab
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Kangas @ 2020-08-12 14:08 UTC (permalink / raw)
To: Matthew Persico; +Cc: 21477
"Matthew Persico (BLOOMBERG/ 919 3RD A)" <mpersico5@bloomberg.net>
writes:
> 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?
Would you be willing to ask the bash maintainers about this?
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2020-08-12 13:51 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-12 14:08 ` Stefan Kangas
@ 2020-08-12 14:54 ` Andreas Schwab
2020-08-12 15:59 ` Stefan Kangas
1 sibling, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2020-08-12 14:54 UTC (permalink / raw)
To: Matthew Persico (BLOOMBERG/ 919 3RD A); +Cc: stefan, 21477
On Aug 12 2020, Matthew Persico (BLOOMBERG/ 919 3RD A) wrote:
> I can reproduce this behaviour, but is it really a bug? Aren't the
> names with '-' invalid?
It's a POSIX extension, enforced in POSIX mode:
13. Function names must be valid shell 'name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2020-08-12 14:54 ` Andreas Schwab
@ 2020-08-12 15:59 ` Stefan Kangas
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Kangas @ 2020-08-12 15:59 UTC (permalink / raw)
To: Andreas Schwab, Matthew Persico (BLOOMBERG/ 919 3RD A); +Cc: 21477
Andreas Schwab <schwab@linux-m68k.org> writes:
> It's a POSIX extension, enforced in POSIX mode:
>
> 13. Function names must be valid shell 'name's. That is, they may not
> contain characters other than letters, digits, and underscores, and
> may not start with a digit. Declaring a function with an invalid
> name causes a fatal syntax error in non-interactive shells.
Right. Well, then adding syntax highlighting here would in a way
encourage people to write non-POSIX conformant shell code, which even if
it happens to work in Bash sounds like a bad idea.
So I'm leaning towards closing this bug report as wontfix.
Any other opinions?
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
2020-08-12 4:15 ` Stefan Kangas
2020-08-12 13:51 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-12 14:36 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-12 15:59 ` Stefan Kangas
2020-08-12 15:57 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Matthew Persico (BLOOMBERG/ 919 3RD A) @ 2020-08-12 14:36 UTC (permalink / raw)
To: stefan; +Cc: 21477
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
Do you have a particular list to ping, or do I try bash-testers or bug-bash?
From: stefan@marxist.se At: 08/12/20 10:08:35To: Matthew Persico (BLOOMBERG/ 919 3RD A )
Cc: 21477@debbugs.gnu.org
Subject: Re: bug#21477: 24.4; Imenu - improper parse of shell function names
"Matthew Persico (BLOOMBERG/ 919 3RD A)" <mpersico5@bloomberg.net>
writes:
> 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?
Would you be willing to ask the bash maintainers about this?
Best regards,
Stefan Kangas
[-- Attachment #2: Type: text/html, Size: 2258 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
` (2 preceding siblings ...)
2020-08-12 14:36 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-12 15:57 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-20 18:13 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-20 18:42 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
5 siblings, 0 replies; 12+ messages in thread
From: Matthew Persico (BLOOMBERG/ 919 3RD A) @ 2020-08-12 15:57 UTC (permalink / raw)
To: schwab; +Cc: stefan, 21477
[-- Attachment #1: Type: text/plain, Size: 1799 bytes --]
I asked on bug-bash:
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.
--
Eli Schwartz
Bug Wrangler and Trusted User
I guess you could go full-on and change the function name match pattern to be a "word" or just add the '-' to it for now to be safe.
From: schwab@linux-m68k.org At: 08/12/20 10:54:40To: Matthew Persico (BLOOMBERG/ 919 3RD A )
Cc: stefan@marxist.se, 21477@debbugs.gnu.org
Subject: Re: bug#21477: 24.4; Imenu - improper parse of shell function names
On Aug 12 2020, Matthew Persico (BLOOMBERG/ 919 3RD A) wrote:
> I can reproduce this behaviour, but is it really a bug? Aren't the
> names with '-' invalid?
It's a POSIX extension, enforced in POSIX mode:
13. Function names must be valid shell 'name's. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid
name causes a fatal syntax error in non-interactive shells.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
[-- Attachment #2: Type: text/html, Size: 3826 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
` (3 preceding siblings ...)
2020-08-12 15:57 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-20 18:13 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
2020-08-20 18:41 ` Stefan Kangas
2020-08-20 18:42 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
5 siblings, 1 reply; 12+ messages in thread
From: Matthew Persico (BLOOMBERG/ 919 3RD A) @ 2020-08-20 18:13 UTC (permalink / raw)
To: schwab, stefan; +Cc: 21477
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
I am not sure what is going on here, but I just loaded up this file and it parsed just fine.
Now, I KNOW that this didn't work when I reported it. And Stefan was able to reproduce it.
I wonder if Stefan can still reproduce?
Since I can't reproduce, I have no issue with closing. If it regresses, I'll open a new issue, making a note of the versions of various packages, which would certainly help diagnosis.
Stefan, it's been a while - can you send me a link to my original bug report?
From: stefan@marxist.se At: 08/12/20 12:00:09To: Matthew Persico (BLOOMBERG/ 919 3RD A ) , schwab@linux-m68k.org
Cc: 21477@debbugs.gnu.org
Subject: Re: bug#21477: 24.4; Imenu - improper parse of shell function names
Andreas Schwab <schwab@linux-m68k.org> writes:
> It's a POSIX extension, enforced in POSIX mode:
>
> 13. Function names must be valid shell 'name's. That is, they may not
> contain characters other than letters, digits, and underscores, and
> may not start with a digit. Declaring a function with an invalid
> name causes a fatal syntax error in non-interactive shells.
Right. Well, then adding syntax highlighting here would in a way
encourage people to write non-POSIX conformant shell code, which even if
it happens to work in Bash sounds like a bad idea.
So I'm leaning towards closing this bug report as wontfix.
Any other opinions?
Best regards,
Stefan Kangas
[-- Attachment #2: Type: text/html, Size: 3056 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2020-08-20 18:13 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-20 18:41 ` Stefan Kangas
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Kangas @ 2020-08-20 18:41 UTC (permalink / raw)
To: Matthew Persico, schwab; +Cc: 21477
"Matthew Persico (BLOOMBERG/ 919 3RD A)" <mpersico5@bloomberg.net>
writes:
> I am not sure what is going on here, but I just loaded up this file
> and it parsed just fine.
Which version of Emacs are you using (M-x emacs-version), and could you
show an example of the code where you see the function name highlighted?
> Stefan, it's been a while - can you send me a link to my original bug report?
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21477
> Right. Well, then adding syntax highlighting here would in a way
> encourage people to write non-POSIX conformant shell code, which even if
> it happens to work in Bash sounds like a bad idea.
>
> So I'm leaning towards closing this bug report as wontfix.
>
> Any other opinions?
I'm still undecided on this point, so other opinions would be welcome.
Perhaps this is something we should support optionally only, so we don't
help unsuspecting users shoot themselves in the foot.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#21477: 24.4; Imenu - improper parse of shell function names
2015-09-14 14:14 bug#21477: 24.4; Imenu - improper parse of shell function names Matthew Persico (BLOOMBERG/ 731 LEX)
` (4 preceding siblings ...)
2020-08-20 18:13 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
@ 2020-08-20 18:42 ` Matthew Persico (BLOOMBERG/ 919 3RD A)
5 siblings, 0 replies; 12+ messages in thread
From: Matthew Persico (BLOOMBERG/ 919 3RD A) @ 2020-08-20 18:42 UTC (permalink / raw)
To: schwab, stefan; +Cc: 21477
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]
At a doctors appointment now. Will do so later this evening.
Sent from Bloomberg Professional for iPhone
----- Original Message -----
From: Stefan Kangas <stefan@marxist.se>
To: MATTHEW PERSICO, schwab@linux-m68k.org
CC: 21477@debbugs.gnu.org
At: 20-Aug-2020 14:41:27
"Matthew Persico (BLOOMBERG/ 919 3RD A)" <mpersico5@bloomberg.net>
writes:
> I am not sure what is going on here, but I just loaded up this file
> and it parsed just fine.
Which version of Emacs are you using (M-x emacs-version), and could you
show an example of the code where you see the function name highlighted?
> Stefan, it's been a while - can you send me a link to my original bug report?
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21477
> Right. Well, then adding syntax highlighting here would in a way
> encourage people to write non-POSIX conformant shell code, which even if
> it happens to work in Bash sounds like a bad idea.
>
> So I'm leaning towards closing this bug report as wontfix.
>
> Any other opinions?
I'm still undecided on this point, so other opinions would be welcome.
Perhaps this is something we should support optionally only, so we don't
help unsuspecting users shoot themselves in the foot.
Best regards,
Stefan Kangas
[-- Attachment #2: Type: text/html, Size: 2619 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread