jsh cannot determine current directory after cwd becomes unavailable #95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
jshcan fail with:This blocks an otherwise valid command from running. The observed command was:
The prompt showed
user@localhost:~, butjshstill reported that it could not determine the current directory.Environment
/Users/user/.local/bin/jshSHELL=/Users/user/.local/bin/jshjdis a small wrapper that sets the user's drive/profile environment and executesjdrive s3 "$@"; the vault password value is intentionally omitted here.jdrivebinary was separately found to contain a stale embedded version string (2.0.18while the repository version was newer). That was corrected independently; it does not explain thisjsherror.Minimal reproduction
The failure is reproducible when a process starts with a directory that has been removed:
Observed output:
The process exits nonzero and does not execute
echo jsh-ran.By contrast, from a valid directory:
works normally.
The
jshbinary also contains the related diagnostic text:What has been ruled out
jerboa-drivechanges its version output but does not remove thejshfailure./Users/user/.local/bin/jdrive versionsucceeds even when launched from a deleted cwd, so this is specific to a path that asks the runtime for the current directory (or to shell command startup), not a universal inability to execute the binary.Possible fixes
current-directoryprimitive return a structured, actionable error forgetcwd()failures, including the underlying errno (ENOENT,EACCES, etc.) and the likely recovery (cdto an existing directory or restart the shell).cd /orcd "$HOME"; silently changing the cwd is probably surprising and should not happen without an explicit user action.., avoid eagerly resolving it throughgetcwd()if the shell can pass it unchanged. If an absolute path is required, use a validatedPWDfallback only with clear safeguards becausePWDmay be stale or attacker-controlled.jsh: cannot determine current directory.jshfrom a directory removed afterchdir(), verifies the current error, and verifies the intended recovery behavior. Also cover inaccessible cwd and symlinked cwd cases.Requested outcome
Please confirm whether this is expected behavior for a deleted/inaccessible cwd and implement the safest recovery/diagnostic behavior. The immediate user impact is that a shell session can look healthy while every command that consults the current directory fails.