example of auto-location of a running scripts path in the file system.
authorFred T. Hamster <fred@mycroft.gruntose.blurgh>
Sat, 14 Jan 2012 03:57:50 +0000 (22:57 -0500)
committerFred T. Hamster <fred@mycroft.gruntose.blurgh>
Sat, 14 Jan 2012 03:57:50 +0000 (22:57 -0500)
does not work for a file that is 'source'd into another bash script.

scripts/examples/script_location.sh [new file with mode: 0644]

diff --git a/scripts/examples/script_location.sh b/scripts/examples/script_location.sh
new file mode 100644 (file)
index 0000000..bdae0fc
--- /dev/null
@@ -0,0 +1,7 @@
+
+# find out the location where this script is running from.  this will not
+# work properly in a bash script that is included via 'source' or '.'.
+# the first letter of each command is escaped to eliminate the danger of
+# personal aliases or functions disrupting the results.
+ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
+