As of OSX 10.10 (Yosemite) and since at least OS X 10.8 (Mountain Lion), the behavior is as follows when you open (double-click) executable scripts from Finder:
.command
:Preferences... > Profiles
you can opt to automatically close the window when the script exits.cd -- "$(dirname "$BASH_SOURCE")"
right after the shebang linecd -- "$(dirname "$0")"
.chmod +x <script>
in Terminal; otherwise, you'll see the following symptoms:.command
: Finder displays a misleading error message that suggests the problem can be fixed via File > Get Info
, which is not true - use the chmod +x
method suggested above.#!/bin/bash
): behavior is as if the suffix were .sh
- see below..sh
, whether executable or not:TextEdit.app
or, if installed, with Xcode.app
..scpt
or .applescript
(even if they're themselves marked as executable, which is not normally the case):
[Apple]Script Editor
[1] Executable means: a script with the executable permission bit(s) set and the calling user - relative to the ownership to the file - therefore potentially being allowed to execute it.
If you use chmod a+x
to set all permission bits (which is typical), anyone can invoke it (assuming they're also allowed to read the file based on the read permission bit(s) and the file's ownership).