Skip to content

Commit 20ddd2a

Browse files
committed
More error messages on failure
Eanbles the activation of environments in the current directory and also warns if there are multiple selections
1 parent 52ac57c commit 20ddd2a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

share/sh_functions/__tykky_get_env_path

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,29 @@ __tykky_get_env_path() {
1919
break
2020
fi
2121
done
22-
22+
if [ -d "$1" ];then
23+
# If there is a matching foldername in the current directory
24+
# and the name does not match anyhing in tykky_path, also test that for convinience
25+
# this is to be consistent with that the first case allows relative paths
26+
# so then relative paths in the current directory withouth / should also work
27+
if [ -z "$__candidate" ];then
28+
__candidate=$PWD/$1
29+
30+
# Ambiguous reference as we might have multiple matches
31+
else
32+
_tp_candidate=$(readlink -f $__candidate)
33+
_d_candidate=$(readlink -f $1)
34+
# if same folder let's not emit a warning
35+
# following pseudo standard -> command line arguments override environment settings
36+
if [ ! "$_tp_candidate" = "$_d_candidate" ];then
37+
echo "WARNING: Multiple candidate tykky environments for $1, activating the one in the current directory" >&2
38+
echo -e "\tfrom TYKKY_PATH: $_tp_candidate" >&2
39+
echo -e "\tfrom current directory: $_d_candidate" >&2
40+
fi
41+
42+
fi
43+
fi
44+
2345
;;
2446
esac
2547

@@ -30,6 +52,10 @@ __tykky_get_env_path() {
3052
else
3153
unset __candidate __tykky_path
3254
echo "ERROR: $1 is not a valid tykky environment" >&2
55+
if [ ! -d "$1" ] ; then
56+
echo -e "\t$1 does not exists or parent folder is not in TYKKY_PATH" >&2
57+
echo -e "\tCurrent value: TYKKY_PATH=$TYKKY_PATH" >&2
58+
fi
3359
false
3460
fi
3561

0 commit comments

Comments
 (0)