-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to check if the is fish? #374
Comments
Maybe this could work:
|
basename? $SHELL is not set by fish. |
Ah, I see. Nevermind then, will think about it. |
You could check for the existence of variables like |
In case a script is not runnable in fish, I want to suggest other shells to execute with that does work, indeed of have a lot of error messages printed out, alternatively use fish version of the script. In case the user use fish as his shell, but /bin/sh links to /bin/bash, bash will be the executing shell but fish's variables will still exist, so checking for variables is not safe. The only safe possibility I can think of is if there is a built in function that will print fish. |
Running a correctly written bash script from fish shouldn't break things. Could you provide a more concrete example? It may help with understanding what type of detection you need, too. |
shells have different syntax compatibility, for example, bash extends posix; The instruction |
That makes sense, but I'm not sure I understand why you'd want to run a bash command in a fish environment? if this is in a script, then wouldn't adding #!/bin/bash at the top work? |
It works on all shells that I have have tested except fish, is I think using #!/bin/sh is preferable. |
The answer at http://stackoverflow.com/questions/3199893/howto-detect-bash-from-shell-script suggests that fish and tcsh both have the It seems like adding an unexported |
Seems like a good idea. (Note that setting /bin/sh to a non-POSIX-sh-compatible shell is a terrible idea, though, and large parts of your system will probably stop working.) |
Naturally that [setting /bin/sh] is a bad idea. |
fish's built-ins are generally compliant (e.g. |
That should do the trick. |
Is it possbile for a shell script to determine if the executing shell is the fish shell?
The text was updated successfully, but these errors were encountered: