How do I get a Mac “.command” file to automatically quit after running a shell script?

前端 未结 7 2205
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 23:47

In my shell script, my last lines are:

...
echo \"$l\" done
done

exit

I have Terminal preference set to \"When the shell exits: Close the wind

7条回答
  •  情深已故
    2021-02-07 00:34

    Short of having to use the AppleScript solutions above, this is the only shell script solution that worked (exit didn't), even if abruptly, for me (tested in OS X 10.9):

    ...
    echo "$l" done
    done
    
    killall Terminal
    

    Of course this will kill all running Terminal instances, so if you were working on a Terminal window before launching the script, it will be terminated as well. Luckily, relaunching Terminal gets you to a "Restored" state but, nevertheless, this must be considered only for edge cases and not as a clean solution.

提交回复
热议问题