Skip to content

fix: read user shell from /etc/passwd when SHELL not exported - #11

Closed
joemckenney wants to merge 2 commits into
mainfrom
joe/issues/10
Closed

joemckenney wants to merge 2 commits into
mainfrom
joe/issues/10

Conversation

@joemckenney

@joemckenney joemckenney commented Feb 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Improvement realized while debugging #10. The root cause of that issue was user error, but in trying to reproduce it became apparent that on Fedora Atomic (Silverblue, Kinoite, Bazzite, etc.), it seems like the SHELL environment variable is set as a shell variable but not exported to the environment. This caused wake to fall back to /bin/sh, which doesn't source .bashrc, so hooks never load.

Root Cause

$ echo $SHELL        # /bin/bash (shell variable)
$ printenv SHELL     # empty (not in environment!)

When std::env::var("SHELL") fails, wake fell back to /bin/sh.

Fix

Now get_user_shell() tries multiple sources:

  1. SHELL environment variable (existing behavior)
  2. /etc/passwd entry for current user (new fallback)
  3. /bin/sh (final fallback)

Test Plan

  • Added 4 unit tests for new shell detection logic
  • All 136 tests pass
  • Verified fix in Fedora 43 container (see scripts/repro-issue-10.sh)

On some systems (notably Fedora Atomic variants), the SHELL environment
variable is set as a shell variable but not exported to the environment.
This caused wake to fall back to /bin/sh, which doesn't source .bashrc,
so the shell hooks never loaded and no commands were recorded.

Now wake tries multiple sources for the user's shell:
1. SHELL environment variable (existing behavior)
2. /etc/passwd entry for current user (new fallback)
3. /bin/sh (final fallback)

Fixes #10

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@joemckenney
joemckenney marked this pull request as ready for review February 1, 2026 17:50
@joemckenney joemckenney changed the title test: reproduction of issue 10 fix: read user shell from /etc/passwd when SHELL not exported Feb 1, 2026
@joemckenney joemckenney closed this Feb 1, 2026
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.

1 participant