Tracker – Terminal communication
If you want to be able to double-click shell scripts to have them executed graphically (e.g. with the assistance of alert boxes), you may discover that the Tracker doesn’t pass the current directory location to the Terminal, and that file copy operations (as might be used for an install routine) don’t work as expected.
The solution is to use a variable like this in your script:
$0 is a special variable with the full pathname of the script. dirname is a command that takes a full path and chops out just the directory portion of it. Assign it to the launchDir variable, and you’ve got the directory the script is sitting in. Very convenient.
Posted in Scripting
(comments are closed).