Reputation: 5729
I have installed bash 4.4.5 using brew
on macOS Sierra, and use it as my primary shell. Due to SIP, I cannot simply upgrade/replace the built-in bash 3.2.57, so it's located in my /usr/local/bin/
directory.
I have scripts in my .bash_profile
that use bash 4.x features such as associative arrays. When I try to run any build process in Sublime Text 3, it is loading the system built-in bash instead of my custom installed bash, and spits our errors every time. Is there any setting or other way of changing which shell Sublime uses?
Might be useful:
$ which -a bash
/usr/local/bin/bash
/bin/bash
$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
$ which -a sh
/usr/local/bin/sh
/bin/sh
$ sh --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Upvotes: 2
Views: 935
Reputation: 22791
The exec
command that is used to perform builds is contained in the Default
package as exec.py
, and is hard-coded to use /bin/bash
to execute a process when using shell_cmd
to specify the command.
There is no configuration option to switch that, so in order to get it to use a different version of bash you would need to create an override of the Default/exec.py
file with the appropriate changes. The easiest way to do that is to use PackageResourceViewer to open the file, then make changes and save it.
Although this will work, note that when a package override such as this exists, Sublime will exclusively use it in place of the file that it is replacing, even if the underlying file has been modified. In this case you don't get told and may be missing out on bug fixes or new features introduced by the package author.
You can mitigate this via OverrideAudit (disclosure: I'm the package author) which among other things will warn you if a package upgrade makes the timestamp on the underlying file newer than your override so that your attention will be drawn to it.
A less intrusive option would be to modify your .bash_profile
to detect the version of bash in use and selectively skip commands that aren't compatible, but depending on what you're using in that file this may or may not be a viable solution.
Upvotes: 1