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

Improve shell detection #312

Merged
merged 1 commit into from Oct 11, 2021
Merged

Conversation

scop
Copy link
Contributor

@scop scop commented May 1, 2021

SHELL in environment is not necessarily the current shell; POSIX
specifies it as the user's preferred one.

Use parent process name primarily instead, if available.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

Case in point, in my Ubuntu 20.04:

$ zsh -lc 'echo $SHELL'
/bin/bash

@scop scop force-pushed the improve-autodetect branch 2 times, most recently from 32b1be0 to 1717bc9 Compare May 2, 2021 16:20
SHELL in environment is not necessarily the current shell; POSIX
specifies it as the user's preferred one.

Use parent process name primarily instead, if available.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
@justjanne justjanne self-requested a review July 14, 2021 17:17
@justjanne justjanne self-assigned this Jul 14, 2021
@scop
Copy link
Contributor Author

scop commented Oct 10, 2021

Just wondering if there's anything I could do to nudge this forward ;)

@justjanne justjanne merged commit 4cbdaf1 into justjanne:main Oct 11, 2021
Comment on lines +85 to +93
var shellExe string
proc, err := process.NewProcess(int32(os.Getppid()))
if err == nil {
shellExe, _ = proc.Exe()
}
if shellExe == "" {
shellExe = os.Getenv("SHELL")
}
cfg.Shell = detectShell(shellExe)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these changes broke some of the BSD builds. Not sure how big of a deal that is, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a gopsutil bug, #345 should fix it.

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

Successfully merging this pull request may close these issues.

None yet

3 participants