From 60ef5bb891844f7c049dd03442c5685897d1b6f0 Mon Sep 17 00:00:00 2001 From: jcs090218 Date: Tue, 21 Feb 2023 12:15:11 -0800 Subject: [PATCH] fix(bin): Resolve the potential symlink to the bash script --- bin/eask | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/eask b/bin/eask index c8f7fe37..02c0343d 100755 --- a/bin/eask +++ b/bin/eask @@ -17,5 +17,19 @@ # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. -BASEDIR=$(dirname "$0") -node "$BASEDIR/../eask" "$@" +function _get_current_directory() +{ + if dirname "$(readlink -f "${0}")" &>/dev/null + then + CDIR="$(cd "$(dirname "$(readlink -f "${0}")")" && pwd)" + elif realpath -e -L "${0}" &>/dev/null + then + CDIR="$(realpath -e -L "${0}")" + CDIR="${CDIR%/eask}" + fi +} + +CDIR="$(pwd)" +_get_current_directory + +node "$CDIR/../eask" "$@"