File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
set -uo pipefail;
4
4
5
+ function realpath-relative-to() {
6
+ # A basic implementation of GNU `realpath --relative-to=$1 $2`
7
+ # that can also be used on macOS.
8
+
9
+ # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
10
+ readlink_f () {
11
+ local target_file=" ${1} " ;
12
+ local file_name;
13
+
14
+ while [ " ${target_file} " != " " ]; do
15
+ cd " $( dirname " $target_file " ) " || early_death " Failed to 'cd \$ (${target_file%/* } )'" ;
16
+ file_name=" ${target_file##*/ } " || early_death " Failed to '\" ${target_file##*/ } \" '" ;
17
+ target_file=" $( readlink " ${file_name} " ) " ;
18
+ done ;
19
+
20
+ echo " $( pwd -P) /${file_name} " ;
21
+ };
22
+
23
+ local relative_to=" $( readlink_f " ${1} " ) " ;
24
+ local path=" $( readlink_f " ${2} " ) " ;
25
+
26
+ echo " ${path# " ${relative_to} /" } " ;
27
+ return 0;
28
+ }
29
+ export -f realpath-relative-to;
30
+
5
31
function tfenv-exec() {
6
32
for _arg in ${@: 1} ; do
7
33
if [[ " ${_arg} " == -c hdir= * ]]; then
8
34
chdir=" ${_arg# -chdir=} " ;
9
35
log ' debug' " Found -chdir arg: ${chdir} " ;
10
- export TFENV_DIR=" ${PWD} /$( realpath -- relative-to= " ${PWD} " " $chdir " ) " ;
36
+ export TFENV_DIR=" ${PWD} /$( realpath- relative-to " ${PWD} " " ${ chdir} " ) " ;
11
37
log ' debug' " Setting TFENV_DIR to: ${TFENV_DIR} " ;
12
38
fi ;
13
39
done ;
You can’t perform that action at this time.
0 commit comments