From 5e492a419c2e767ca01bfd2f26639c2970929bd0 Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Wed, 23 Jul 2014 11:29:42 +0200 Subject: [PATCH] DIR and FILE are actually local vars, so lowercase Also improve pathfinding to not rely on readlink, and to work as expected when file is sourced --- main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.sh b/main.sh index 7933789..5753fa7 100755 --- a/main.sh +++ b/main.sh @@ -37,8 +37,8 @@ read -r -d '' usage <<-'EOF' EOF # Set magic variables for current FILE & DIR -__FILE__="$(test -L "$0" && readlink "$0" || echo "$0")" -__DIR__="$(cd "$(dirname "${__FILE__}")"; echo $(pwd);)" +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +__file="${__dir}/$(basename "${0}")" ### Functions