prefix-dev / shell

The ultimate cross-platform, bash-like shell
MIT License
63 stars 9 forks source link

Implement $SHELL and $0 (How to identify which shell I am in) #81

Open certik opened 2 months ago

certik commented 2 months ago

The shell now looks identical to Bash! How can I tell which shell I am in? This morning I started in our shell, and I only noticed when git tab completion didn't work (#80) that I am not in Bash.

certik commented 2 months ago

Some ideas:

awvwgk commented 2 months ago

For shells like Bash or Zsh the shell running is always exported in the SHELL environment variable.

certik commented 2 months ago

@awvwgk great idea! Indeed, $SHELL works, so we should just implement it and that will fix this for me.

certik commented 1 month ago

Apparently there is also $0:

$ echo $0
-bash
gxyd commented 1 month ago

For shells like Bash or Zsh the shell running is always exported in the SHELL environment variable.

I think there is a difference between $SHELL and $0, as provided here:

https://stackoverflow.com/questions/9804517/difference-between-0-and-shell#:~:text=%24SHELL%20gives%20the%20full%20path,name%20of%20your%20current%20shell.

certik commented 1 month ago

I see. The $SHELL environment variable is a shell that the user wants to be using for future shell invocations from various programs. That's a separate feature.

The main feature I want in this issue is to determine which shell I am running right now, and for that we need to implement $0 which will print the currently running program (shell).