#!/bin/bash vs /opt/homebrew/bin/bash

New to Bashsupport pro, sorry for the basic question, when I create my first project/file the header is #!/bin/bash, but, the plug in (BashSupport) installed the latest bash version via homebrew in /opt/homebrew/bin/bash, shouldn’t that be the header? Thanks

Welcome onboard! :slight_smile:

The header #!/bin/bash is called a shebang line and is the default because usually all systems have Bash installed at that path. An alternative is #!/usr/bin/env bash, which executes the env command to execute with bash found in the $PATH.

By default, BashSupport Pro’s run configuration executes with the shebang command (i.e. /bin/bash) if the script is executable. This is the same way the OS is handling execution via ./my-script.bash.

If you’d like to execute with /opt/homebrew/bin/bash, then I suggest to change the interpreter type of the run configuration to “Default Bash Interpreter” instead of “Automatic”. See Settings of BashSupport Pro's run configurations – BashSupport Pro for these settings.

BashSupport Pro does not install Bash, but relies on the system’s setup. Did BashSupport Pro appear to install Bash via homebrew?

If you installed Bash via homebrew, BashSupport Pro should pick it up. If it doesn’t, you could add the interpreter in the settings linked above.

If /opt/homebrew/bin/bash was put as shebang line, then the created script would only run with this very specific setup and nowhere else.

Please let me know if this doesn’t answer your question or if you need help with anything else to get started!

Thank you for the explanation, yes, once I installed the BashSupport Pro extension a new Bash was installed, version 5.2, my concern is that the default bash (apple) is 3.9, I am confused why the extension installed another Bash if there was already one in the system?

If the script by default points to bash 3.9 what’s the purpose of installing 5.2 with the extension? maybe is bashdb (debugger) requirement?

Please could you clarify,

Update:

Now if bashdb requires bash 5.2 the default on the scripts should be to point to this bash if not the debugger will not work?

I’m not sure why you’re thinking that BashSupport Pro installed a new version of Bash on your system.
BashSupport Pro is detecting the installed interpreters, but it’s not installing them. There’s no code in the plugin to modify your system’s setup or to install a Bash interpreter.
Please clarify how you installed BashSupport Pro if you’re certain that there was no previous installation of Bash 5.x on your system.

The bashdb formula is not used by BashSupport Pro. It’s bundling its own distributions of bashdb for Bash 4.x and of bashdb for Bash 5.x.

It’s true that debugging with Bash 3.x (the default on macOS) is not possible, that version is just too old.
BashSupport Pro attempts to use a compatible version of Bash for debugging, even if the shebang line is /bin/bash. There’s a different implementation to detect Bash for running and debugging. For debugging, the configured interpreters at Settings > Languages & Frameworks > BashSupport Pro > Shell interpreters are used.

Have you tried to debug a Bash script with BashSupport Pro?
Please let me know if if doesn’t work for you and I’ll try to help you fix it.

Thank you for the great support, I think what happened is that BashSupport installed bashdb, and basdb requires bash 5.2, I see from the Shell Interpreters screen that the correct path is in there:

/opt/homebrew/bin/bash

BashSupport Pro bundles bashdb with the plugin distribution (which is downloaded by the IDE).
It does not run homebrew (or another package manager) to install a package on the system. The bashdb package of homebrew is not needed to debug shell scripts with BashSupport Pro.

The interpreter settings look good to me. You can click on the icon with the two arrows to re-detect interpreters on your system, e.g. when you installed another version of Bash or Zsh.

Anyway, if running and debugging of scripts via BashSupport Pro is working for you, then everything should be alright :slight_smile: