-
Notifications
You must be signed in to change notification settings - Fork 41
/
env.sh
48 lines (37 loc) · 852 Bytes
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Usage: Source this file as:
# $> source ./env.sh
export TK_SILENCE_DEPRECATION=1
readlink_osx()
{
target_file="$1"
dir_name=$(dirname "$target_file")
cd "${dir_name}" || exit
target_file=$(basename "$target_file")
# Iterate down a (possible) chain of symlinks
while [ -L "$target_file" ]
do
target_file=$(readlink "$target_file")
cd "$(dirname "$target_file")" || exit
target_file=$(basename "$target_file")
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
phys_dir=$(pwd -P)
result="$phys_dir/$target_file"
echo "$result"
}
readlink_()
{
case $OSTYPE in
darwin*)
readlink_osx "$1"
;;
*)
readlink -f "$1"
;;
esac
}
script=$(readlink_ "$0")
script_path=$(dirname "$script")
export PATH="${script_path}/bin":$PATH