After upgrading to a new machine and Ventura it no longer worked, stating it needed at least bash 4.0. So, I installed bash via homebrew and at least from within the terminal I can use the script and it works fine.
Making it work with the "Execute Shell Script" action is another deal, though. I read the wiki as well as the corresponding posts, but I seem to miss something. Whatever I do, it doesn't help. Any ideas where I need to look more or where the issue might be is greatly appreciated.
Some context information
Executing #!/bin/sh echo "$SHELL" always returns "/bin/zsh". No matter if I set the variable "ENV_PATH" or not. I tried setting it to "/opt/homebrew/bin/bash". At this point, if I try to run the script the KM notification says:"bash command not found".
In the terminal bash --version brings me GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin22.1.0) and the script itself works fine.
If, back in KM, I empty the ENV_Path and add #!/bin/bash the notification gives me the compatibility issue due to bash being outdated. If I add back the correct path, I get the command bash not found information.
I feel a bit confused and don't really know where to look next. Any ideas?
But that's by-the-by. You'll need to start your "Execute Shell Script" action's script with a "shebang" line pointing at your desired bash -- so something like
#!/opt/homebrew/bin/bash
# script goes here...
You may also need to add /opt/homebrew/binto KM's ENV_PATH, depending on whether or not the script calls other brew-installed items.
That should point you in the right direction -- if not, post your actual macro (or at least the "Execute Shell Script" action).
...while the first line of ~/Dekstop/ots.bash should be changed to
#!/opt/homebrew/bin/bash
...so the interpreter uses the right version.
(At the moment you're saying "Hey, KM! Use bash v5 to change directory and run this script". bash5 opens the file, reads the first (shebang) line and is told that the following script should be interpreted by your default bash v3. Since I'm working blind I'm suggesting to explicitly run this script with v5 rather than changing things so all KM bash scripts use v5, because who knows what that might break!)
My worry is always that changing the default bash might break other things that don't want v5... Only OP knows which will be more painful -- individually setting those things that need v5 or individually setting those things that need v3.
(Yes, I've seen a self-proclaimed Bioinformatics guru fubar his own project pipeline doing this. Had a hard time getting out of the room before bursting into laughter )
Thank you very much @Nige_S and @ccstone - both of your replies helped me solve the problem.
The hint changing the shebang within the script totally made sense once I read it. Before that, it didn't really cross my mind. Once I did that I got a dependency error which was kind of weird because I did install it. This is where the macro posted by @ccstone really helped me set the ENV_PATH variable correctly.
After combining both, the script finally works. Yay!
Thanks again, guys. I greatly appreciate your help!
EDIT: @ccstone Within your macro I had to replace the first menu action with "Settings" because I got a small notice saying the menu item "Preferences" couldn't be found.
Of course. Here you go. This works on Ventura with KM 10.2. I don't know, but could this not also be solved by invoking "Command + ," which universally opens the preferences?