Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_hwloc-info: not a valid identifier #381

Closed
kaipee opened this issue Jan 22, 2020 · 5 comments
Closed

_hwloc-info: not a valid identifier #381

kaipee opened this issue Jan 22, 2020 · 5 comments

Comments

@kaipee
Copy link

kaipee commented Jan 22, 2020

What version of hwloc are you using?

2.1.0-2

Which operating system and hardware are you running on?

Arch Linux
Linux gb-lis-sys-21 5.4.13-arch1-1 #1 SMP PREEMPT Fri, 17 Jan 2020 23:09:54 +0000 x86_64 GNU/Linux

Details of the problem

Symptoms of the issue are : failure to login to gnome-session (xorg) via GDM.

Logs show an error with the bash-completion file
/etc/bash_completion.d/hwloc-completion.bash: line 193: _hwloc-info: not a valid identifier

Removing the bash-completion package resolves the login issue.

Additional info

https://bbs.archlinux.org/viewtopic.php?pid=1884144#p1884144

@bgoglin
Copy link
Contributor

bgoglin commented Jan 22, 2020

Does a plain bash (not GDM) also report the same error? If so, which version of bash do you have? My bash 5.0.11 looks happy.

@bgoglin
Copy link
Contributor

bgoglin commented Jan 22, 2020

It looks like '-' is not allowed in bash function names (while '_' is allowed). Maybe it changed in recent bash releases. If you can confirm that renaming _hwloc-info to _hwlocinfo where it's defined and used (and remove the rest of the file because there are many other functions with the same issue), I'll fix that quickly.

@kaipee
Copy link
Author

kaipee commented Jan 22, 2020

Does a plain bash (not GDM) also report the same error? If so, which version of bash do you have? My bash 5.0.11 looks happy.

Yes simply logging in from tty works fine via startx.

@kaipee
Copy link
Author

kaipee commented Jan 22, 2020

It looks like '-' is not allowed in bash function names (while '_' is allowed). Maybe it changed in recent bash releases. If you can confirm that renaming _hwloc-info to _hwlocinfo where it's defined and used (and remove the rest of the file because there are many other functions with the same issue), I'll fix that quickly.

Yes I have confirmed that correcting the BASH function/alias works.

s/hwloc-info/hwlocinfo/g works fine

bgoglin added a commit that referenced this issue Jan 22, 2020
According to the manpage, it's forbidden.
However it seems to work fine in the majority of cases.

Thanks to Keith Patton for the report (GDM failure on Arch)

Closes #381

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
@buczek
Copy link

buczek commented Aug 17, 2022

Just for reference:

https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html

  • "When invoked as sh, Bash enters POSIX mode after reading the startup files."
  • [ when ‘POSIX mode’ is in effect ] "Function names must be valid shell names. 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."

So the problem might appear, for example, on systems which use bash as /bin/sh and then bash is invoked via such a path by the shell setting of the user or a tool with a hardcoded /bin/sh path or a script with a #! /bin/sh shebang. Additonally, the script needs to explicitly call . ~/.bashrc (if the shell completion is configured there), because bash wouldn't do so by itself in POSIX mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants