6,787
Loading...
Uploader Comments (macheads101)
see all
All Comments (34)
-
I put my script files in a .dmg (disk image)
-
@d4ir3 You have to remember to say the file name after chmod +x
-
@thecomputerist thats implied in the tutorial where I show rm...
-
did he already teach us the rm-rf / ?
-
its not working for some reason... do you need a certain software?
Loading...
This is the best Mac script. :(){:|:}
Lol, seriously, though its nice to see Mac users learning some basic UNIX skills instead of assimilating everyone into the Apple hivemind.
By the way, using killall Terminal is overkill because it will kill other terminal sessions the user may have open. You can easily put "exit" at the end and that should close the terminal. If it doesn't there's probably a better way to grab the PID of the current instance of terminal and doing a kill $PID.
-Linux user
LTS1287 4 months ago
@LTS1287 Some people (including myself) have terminal set to keep it's windows open, even after the shell exists. This is useless for running UNIX executables through the GUI, since the Terminal window stays open even after the script terminates. Therefore, "killall Terminal" is the best way to do it in this case.
macheads101 4 months ago
@macheads101: Well that's just one use case, though. You have to find the best possible solution to accommodate all use cases. Software Engineering 101, buddy. :) Getting the PID of that single terminal would work across the board for users of any UNIX variant. You could make a simple bash script and put it in a video to teach more advanced shell scripting to your audience. I'm sure you could open a terminal and have it run a command with something like terminal -c `foo`. Then do a pidof.
LTS1287 4 months ago
@LTS1287 Since this tutorial is aimed towards Mac users, it is ideal to "killall Terminal", since only one instance of an app can run at once. In a Linux environment it would be ideal to only kill the active terminal instance, since Linux doesn't share the "one instance of an app can run at once" philosophy. This was aimed at teaching users how to quickly write a shell script, not to show them how to exhaust all possible environments in which their script may be running.
macheads101 4 months ago
@macheads101 Although I will admit that it would be more ideal to use some sort of AppleScript magic to close the active terminal window without affecting the others. Unfortunately, doing something like that would only further confuse my viewers, causing an increased number of dislikes on the video ;)
macheads101 4 months ago