From 1a1b11f4304dc7b9e3e9e86ac8680d9997fc01ff Mon Sep 17 00:00:00 2001 From: Radu Ciorba Date: Sat, 12 Aug 2017 01:25:16 +0300 Subject: suggest the correct activate script based on parent process command Looks at parent process command and suggests sourcing the appropriate activate script for fish and csh. fixes #224 --- kerl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kerl b/kerl index b292ea3..9e9d55c 100755 --- a/kerl +++ b/kerl @@ -932,8 +932,23 @@ ACTIVATE_CSH build_plt "$absdir" fi + PID=$$ + PPID=$(ps -p $PID -o ppid | grep -E "[0-9]+" -o) + PARENT_CMD=$(ps -p $PPID -o comm | tail -n 1) + case "$PARENT_CMD" in + fish) + SHELL_SUFFIX=".fish" + ;; + csh) + SHELL_SUFFIX=".csh" + ;; + *) + SHELL_SUFFIX="" + ;; + esac + echo "You can activate this installation running the following command:" - echo ". $absdir/activate" + echo ". ${absdir}/activate${SHELL_SUFFIX}" echo "Later on, you can leave the installation typing:" echo "kerl_deactivate" } -- cgit v1.2.3 From 69d3c0f1f24d58b3a7327ce15ba1e23e8a01e3f3 Mon Sep 17 00:00:00 2001 From: Radu Ciorba Date: Sat, 12 Aug 2017 02:21:27 +0300 Subject: avoid PPID since it's used and readonly on mac + use ps -o ucomm PPID variable already used and readonly on Mac. ps's output flag comm is not consistent between Mac and Linux+FreeBDS, but ucomm seems to work everywhere --- kerl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kerl b/kerl index 9e9d55c..034c341 100755 --- a/kerl +++ b/kerl @@ -933,8 +933,8 @@ ACTIVATE_CSH fi PID=$$ - PPID=$(ps -p $PID -o ppid | grep -E "[0-9]+" -o) - PARENT_CMD=$(ps -p $PPID -o comm | tail -n 1) + PARENT_PID=$(ps -p $PID -o ppid | grep -E "[0-9]+" -o) + PARENT_CMD=$(ps -p $PARENT_PID -o ucomm | tail -n 1) case "$PARENT_CMD" in fish) SHELL_SUFFIX=".fish" -- cgit v1.2.3