X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=infobase%2Fexamples%2Fbashisms%2Fscript_location.sh;fp=infobase%2Fexamples%2Fbashisms%2Fscript_location.sh;h=7fa942a6302f90daba31cd31c49a686c3ef4def4;hb=8f403891425dfe131948be97cae4edf21f3f7869;hp=0000000000000000000000000000000000000000;hpb=a4d12589f1cd01826814842cde0b3eac95890bc9;p=feisty_meow.git diff --git a/infobase/examples/bashisms/script_location.sh b/infobase/examples/bashisms/script_location.sh new file mode 100644 index 00000000..7fa942a6 --- /dev/null +++ b/infobase/examples/bashisms/script_location.sh @@ -0,0 +1,10 @@ + +# 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")" && /bin/pwd )" + +# another slightly tighter version: +export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory. +