The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

Tracker – Terminal communication

Contributed by: Keith Dunnigan aka Parakeet
This tip is valid for: Both BeOS and Haiku

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:

launchDir=$(dirname $0)

$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).