From 8a6e04d962f84b85aac5678f6bbf9528d73a7253 Mon Sep 17 00:00:00 2001 From: Ashwanth Kumar Date: Mon, 8 Aug 2016 10:24:21 +0530 Subject: [PATCH] Adding BASE_DIR to the files being shebang aware --- mesos-fix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mesos-fix b/mesos-fix index c3950fb..d9432ea 100755 --- a/mesos-fix +++ b/mesos-fix @@ -13,7 +13,10 @@ APP_PATH=${APP_PATH:-/app/} add_base_path_on_top_in() { FILE=$1 if [ -f $FILE ]; then - sed -i '1i export BASE_PATH=$(cd `dirname $BASH_SOURCE`; pwd -P)/../' $FILE + # Add after the shebang in the file + sed -i '/#\!/a export BASE_PATH=$(cd `dirname $BASH_SOURCE`; pwd -P)/../' $FILE + # Add to the BOF if shebang is not present + egrep "#\!" $FILE || sed -i '1i export BASE_PATH=$(cd `dirname $BASH_SOURCE`; pwd -P)/../' $FILE fi }