-
-
Notifications
You must be signed in to change notification settings - Fork 647
fix(detection/terminalshell): use absolute path to shell if available #2067
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
Conversation
8d5ee27 to
eacb22a
Compare
|
Do the same for terminals? |
1 similar comment
|
Do the same for terminals? |
Yes, if you could give me the code location, I can try fixing that too. |
|
Well, you know the file you modified is called |
|
Oh it's in the same file. Wait for me... |
|
e914504 fixes terminal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modifies the terminal and shell detection logic to prefer absolute paths (exePath) over executable names (exe) when available. The change ensures that the correct shell binary is used for version detection, avoiding cases where the executable name might resolve to a different location than the actual login shell.
Key Changes
- Refactored shell version detection functions to accept only the executable path parameter, removing the separate
exePathparameter - Added logic to select
exePathoverexewhenexePathis available before calling version detection functions - Applied consistent handling across both Windows and Linux platforms
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| terminalshell_windows.c | Selects exePath over exe when available before calling fftsGetTerminalVersion |
| terminalshell_linux.c | Selects exePath over exe when available before calling fftsGetTerminalVersion |
| terminalshell.c | Refactored getShellVersionBash and getShellVersionZsh to remove exePath parameter and added path selection logic in fftsGetShellVersion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
What was the bug that this issue & PR intended to fix? The stated rationale is:
On Linux, at least, these are extracted from a running process's /proc/pid/exe, and will only resolve to different files if the original file has been removed or otherwise changed since the running shell-under-examination was started. The For example, on my desktop (Debian 'sid', different from the Termux I was reporting on in #2136): Here, indeed, But these ( I don't think this change (5d13389) can have fixed an actual behavior bug; and instead it introduced one, since it causes |
|
Actually, I think I may be misreading slightly what the change does. If it effectively changed it from running But the solution of decoding /proc/pid/exe's symlink target -- that does not work. Use what |
Well no, for login sessions on most UNIX-like platforms Ubuntu: $ ps
PID TTY TIME CMD
42947 pts/0 00:00:00 zsh
$ fastfetch -l none -s shell --format json
[
{
"type": "Shell",
"result": {
"exe": "zsh",
"exeName": "zsh",
"exePath": "/usr/bin/zsh",
"pid": 42947,
"ppid": 42946,
"processName": "zsh",
"prettyName": "zsh",
"version": "5.8.1",
"tty": 0
}
}
]mac: $ ps
PID TTY TIME CMD
9802 ttys000 0:00.30 -zsh
$ fastfetch -l none -s shell --format json
[
{
"type": "Shell",
"result": {
"exe": "zsh",
"exeName": "zsh",
"exePath": "/opt/homebrew/bin/zsh",
"pid": 9802,
"ppid": 9801,
"processName": "zsh",
"prettyName": "zsh",
"version": "5.9",
"tty": 0
}
}
] |
|
I might instead argue that the user’s login shell should be detected from |
Sometimes shell executable name (
exe; e.g.,zsh) might resolve to a different path than path to the login shell (exePath; e.g.,/bin/zsh). This PR tries to use absolute path to the login shell if possible, and fallback to previous behavior if absolute path is not available.