Skip to content

fix(builtins): command -v/-V now searches PATH for external scripts#1134

Merged
chaliy merged 3 commits intomainfrom
fix/issue-1120-command-v-path
Apr 7, 2026
Merged

fix(builtins): command -v/-V now searches PATH for external scripts#1134
chaliy merged 3 commits intomainfrom
fix/issue-1120-command-v-path

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 7, 2026

Summary

  • command -v and command -V only checked builtins, functions, and keywords — never PATH
  • Now they also search PATH directories on the VFS for executable scripts, matching real bash behavior
  • command -v myscript prints the resolved path (e.g. /scripts/myscript)
  • command -V myscript prints myscript is /scripts/myscript
  • Added resolve_command_path() helper that does read-only PATH lookup without execution

Test plan

  • Spec test: command_v_finds_builtin — finds echo as builtin
  • Spec test: command_v_finds_function — finds user-defined functions
  • Spec test: command_v_not_found — returns exit 1 for unknown commands
  • Spec test: command_v_searches_path — finds executable scripts on PATH
  • Spec test: command_V_builtin — "echo is a shell builtin"
  • Spec test: command_V_path_script — "pathcmd is /scripts/pathcmd"
  • All 2023+ existing tests pass

Closes #1120

chaliy added 3 commits April 7, 2026 00:27
command -v and command -V only checked builtins, functions, and
keywords. Now they also search PATH directories on the VFS for
executable scripts, matching real bash behavior. command -v prints
the resolved path; command -V prints "name is /path".

Closes #1120
@chaliy chaliy merged commit 62daa97 into main Apr 7, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1120-command-v-path branch April 7, 2026 00:57
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.

fix(builtins): command -v does not search PATH for external scripts

1 participant