"Shebang At Top of Shell Script" not working?

Hi,

So i've read Execute a Shell Script and How to Use Shebang at Top of Shell Script.

I tried everything, but can't seem to set the shell to "bash" and execute a bash shell script.

Here's the most minimal example showing the issue. The shell is still "fish" even though i tried setting it to "sh".

Please advise, thank you!

test_bash.kmmacros (1.7 KB)

Output:

shell is: /opt/homebrew/bin/fish
shell file is here: -rwxr-xr-x  1 root  wheel  101232 Aug  4 12:31 /bin/sh

I don't think that the value of $SHELL tells us which shell is running.

(Just what the user's login shell is)

( Perhaps try ps -p $$ for that)

Note that, by default:

the Execute a Shell Script action executes a specified shell script using /bin/sh

action:Execute a Shell Script [Keyboard Maestro Wiki]

1 Like

You are correct.. thank you for the tip!
The correct way is to display the current shell in use is:

echo "shell is: $(ps -p $$)"

Also, i fixed the problem. The original issue i had was the PATH not being set correctly; the reason was i has a space somewhere as seperator (due to this being the FISH notation) instead of a : which is used in BASH.

Thank you!

1 Like