Skip to content

Output from which command for builtins is not following the behavior of bash #20

Description

@neerfri

Bug Description

While working on #19 I noticed that the behavior for "which " is different than the expected output of bash.
This is an easy fix but before submitting the PR I wanted to make sure there is no reason for why JustBash behaves this way.
I think this might be confusing to AI agents that will assume they can read the file that which is pointing to but in this case they cannot since it's a builtin.

In bash:

❱ which echo
echo: shell built-in command

In JustBash:

❱ mix run -e 'bash = JustBash.new(); {result, _bash} = JustBash.exec(bash, "which echo"); IO.puts(result.stdout)'
/bin/echo

To Reproduce

bash = JustBash.new()
{result, _} = JustBash.exec(bash, "which echo")
result.stdout
# Expected: "echo: shell built-in command"
# Actual: "/bin/echo"

Expected Behavior

I expect the output of which to follow the behavior of bash. builtins have no path.

Actual Behavior

JustBash fakes a path that does not exist

Environment

  • Elixir version: [e.g., 1.17.0]
  • OTP version: [e.g., 27.0]
  • JustBash version: [e.g., 0.1.0]
  • OS: [e.g., macOS 14.0, Ubuntu 22.04]

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions