Skip to content

Respect the process name when detecting a login shell - #103

Open
jovial-liu wants to merge 1 commit into
sarugaku:masterfrom
jovial-liu:fix/login-shell-process-name
Open

jovial-liu wants to merge 1 commit into
sarugaku:masterfrom
jovial-liu:fix/login-shell-process-name

Conversation

@jovial-liu

Copy link
Copy Markdown

macOS Terminal can start -fish while $SHELL still points to /bin/zsh. Shellingham currently trusts $SHELL whenever the process command starts with a dash, so it reports zsh and consumers can choose the wrong completion setup.

Use $SHELL's full path when its basename matches the process-reported shell name. Otherwise strip the leading dash and continue normal known-shell or interpreter detection, including the parent-process fallback. Add regression coverage and a bugfix news fragment.

Fixes #86, following the basename-comparison direction in the maintainer's comment.

Validation on macOS:

  • New cases against the original source: 6 failed, 8 passed.
  • Full suite after the fix: 14 passed on CPython 3.12.14 with pytest 9.1.1, and 14 passed on CPython 3.9.6 with the test dependency versions from Pipfile.lock (pytest 7.4.2). Command: PYTHONPATH=src python -m pytest -q.
  • Actual macOS PTY process with Bash argv[0] -bash and SHELL=/bin/zsh: original detect_shell() returned ('zsh', '/bin/zsh'); patched code returned ('bash', 'bash').
  • Wheel and source distribution built successfully.
  • Ruff's E4/E7/E9/F checks passed; Black passed for the changed production module. Broader latest-Ruff and Black checks report existing baseline issues in unchanged files; those checks are not claimed as passing.

Prepared and tested with OpenAI Codex, with an independent agent code review. No manual human review is claimed.

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.

Dash prefix does not always imply login shell

1 participant