Anthony
Anthony

Reputation: 83

Can't Get Shell Scripts to Run

I recently reinstalled Mojave on my Macbook Pro. Before the install, I had several bash scripts written, all of which were executable by double-clicking on them. They are all .command extensions. For each file, I ran chmod +x to make it executable. The shebang in each of the scripts is: #! /usr/bin/env bash

After the install, I cannot get the scripts to run by double-clicking. If I access the scripts through terminal, they run fine. But if I double-click, it opens a terminal window with the title of the script, but nothing happens, the script never executes.

I installed bash through homebrew, then entered /usr/local/bin/bash into /etc/shells. In terminal, if I enter which bash it returns /usr/local/bin/bash. If I enter echo $SHELL it returns /bin/bash.

I want my system to be running the bash 5 that homebrew installed. I thought I had my terminal configured correctly, but I can't figure this out. Any help would be extremely appreciated.

I attached a screenshot of the terminal output too in case it would be helpful. I wrote a script for an example titled "hello.command":

#! /usr/bin/env bash

echo 'Hello'

This is what shows up if I double click it:

enter image description here

Upvotes: 1

Views: 351

Answers (1)

Mihir Luthra
Mihir Luthra

Reputation: 6779

In /etc/shells, add an entry on a newline:

/usr/local/bin/bash

Note that to add this entry to /etc/shells, you need root privileges.

Upvotes: 2

Related Questions