From 31795d379b8a94e37465677f5776c47a476a0f64 Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Fri, 13 Jan 2012 22:57:50 -0500 Subject: [PATCH] example of auto-location of a running scripts path in the file system. does not work for a file that is 'source'd into another bash script. --- scripts/examples/script_location.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 scripts/examples/script_location.sh diff --git a/scripts/examples/script_location.sh b/scripts/examples/script_location.sh new file mode 100644 index 00000000..bdae0fc7 --- /dev/null +++ b/scripts/examples/script_location.sh @@ -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 )" + -- 2.34.1