Quote:
Originally Posted by
Don Cragun
If (on macOS Mojave version 10.14.3) I:
- create an executable shell script,
- open the Finder application,
- in Finder go to the directory containing the script I just created,
- then right click on the name of that script, and
- select "Make Alias"
it creates a new file in the same directory with the name
script alias (where
script is the name of the file I right-clicked on in
Finder) with the name of that file selected. I can then enter a new name for that alias or change the focus it I want to keep that name for the alias.
This is the same process I used to create the alias (on MacOS 10.13.6, a bit behind yours).
Quote:
Originally Posted by
Don Cragun
Note that I did not need to run the script to create the alias.
It was not creating the alias that required me to run the script. When I double click on my alias, the script opens in Text Editor instead of running in Terminal. Unlike a windows shortcut or Linux launcher, the alias doesn't have a property to let you specify the program you want to open the file in. In order to get the script to run in Terminal, I had to do the steps I described to define "open with" for the script file (not the alias file). This is the procedure where I had to actually run the script in order to specify the "open with" program. Once I had done that, I could double click on the script (or on the alias) and it would run in Terminal. I actually don't know if this now applies to all files on the system with the .sh extension, or just the one script file. The alias works in any location where it's located. I believe this is just a symbolic link like ln.
Quote:
Originally Posted by
Don Cragun
If I then double-click on the name of the alias in Finder, it opens a new window, runs the script in that window, and when the script exits, the window disappears.
If I move the file created onto my desktop and double-click on it there, macOS opens a new window, runs the script in that window, and when the script exits, the window disappears.
After having set the "open with" value for the script file, when I double click on the alias file, a terminal window opens, the script runs, and finishes, but I get the
[Process completed] message and the Terminal sits there in a non-functional state without the window closing.
Quote:
Originally Posted by
Don Cragun
In either of the above cases, the window is running an interactive shell and can accept keyboard input in response to prompts issued by the script. If the script isn't expecting user input, I can minimize the window or move it behind other open windows and it will continue running until the script exits (and then the window disappears). Is that what you want to have happen?
This is what I want, I just don't know why the Terminal window closes when the script is finished on your system and stays open on mine. I have run this script on both windows and linux for a long time and I have never seen that before.
LMHmedchem