Skip to content

Commit

Permalink
v0.3
Browse files Browse the repository at this point in the history
bugfix: relative path symlinks
  • Loading branch information
JayBrown committed Oct 23, 2020
1 parent 19192b6 commit 38a40d7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions linker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/zsh
# shellcheck shell=bash

# Linker v0.2
# Linker v0.3

export LANG=en_US.UTF-8
export SYSTEM_VERSION_COMPAT=0
Expand Down Expand Up @@ -40,8 +40,8 @@ _relpath () {
# components may be ".", ".." or a symbolic link
#
# returns relative path to $2/$target from $1/$source
source=$1
target=$2
source=$1 # link location
target=$2 # original file

if [[ $(dirname "$source") == $(dirname "$target") ]] ; then
result=$(basename "$target")
Expand Down Expand Up @@ -86,7 +86,9 @@ _relpath () {
result=${forward_part#?}
fi
fi


result=$(echo "$result" | sed "s-^\.\./--" 2>/dev/null)

printf '%s\n' "$result"
}

Expand Down

0 comments on commit 38a40d7

Please sign in to comment.