1

Issue:

When I try to open any shell scripts a new window is spawned, which exits immediately. Files .bash_profile, .bashrc and a helloworld.sh are tested examples.

Interestingly, running open helloworld.sh outputs:

Jake:~ jakebanks$ /Users/jakebanks/helloworld.sh; exit;
Hello World!
logout

Which seems to say it executed successfully. The output of echo ${PIPESTATUS[0]} (in the first window) is 0.

Config:

Recently I changed my default terminal to iTerm2, and this is the most recent change I can recall making before having this issue.

  • Default text editor is Sublime Text 2.
  • Default shell is bash.
  • FWIW, the issue is terminal agnostic.

Contents of .bash_profile are (for now):

PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PATH

The contents of .bashrc:

#!/bin/bash
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/jakebanks/.sdkman"
[[ -s "/Users/jakebanks/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/jakebanks/.sdkman/bin/sdkman-init.sh"

What I've tried:

  • Changing shells
  • Opening non-shell-script files (e.g. text files) with success
  • Resetting profiles to their defaults in both Terminal and iTerm2

Solution:

It turns out that I was confused about how shell scripts are invoked from the terminal. The command actually should have been sh helloworld.sh, rather than open helloworld.sh

  • You need to change your filetype associations (somehow). – Michael Homer Dec 12 '15 at 6:55
  • Thanks for the reply. I have taken a look and it appears Sublime Text is set to be the default program for the .bash_profile and .bashrc extensions. Could this be a problem? – Jake Banks Dec 12 '15 at 9:23
  • 1
    Right click on a file with the desired extension->get info->open with (change app), and click in "change all" and then "continue". Please in next posts, specify you are talking about OS/X at the beginning of the post. – Rui F Ribeiro Dec 12 '15 at 11:38
  • Hi Rui, the difficulty I am having is now how to change the associations, but knowing which ones being set incorrectly could be causing my problem. Thank you. – Jake Banks Dec 22 '15 at 4:53
  • @RuiFRibeiro - it says, right at the top of the post, in the address bar: unix.stackexchange.com. – mikeserv Jan 1 '16 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.