2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2010-2014 Intel Corporation
6 # print the relative path of $1 from $2 directory
7 # $1 and $2 MUST be absolute paths
13 echo " $0 path1 path2"
17 # get the real absolute path, derefencing symlinks
18 ABS1="$(dirname $(readlink -f $1))/$(basename $1)"
19 ABS2=$(readlink -f $2)
21 # remove leading slash
37 while [ "${right1}" != "" -a "${right2}" != "" ]; do
39 if [ "$left1" != "$left2" ]; then
44 left1=$left1/${right1%%/*}
46 right1=${prev_right1#*/}
47 if [ "$right1" = "$prev_right1" ]; then
52 left2=$left2/${right2%%/*}
54 right2=${prev_right2#*/}
55 if [ "$right2" = "$prev_right2" ]; then
60 if [ "${left1}" != "${left2}" ]; then
65 while [ "${right2}" != "" ]; do
69 if [ "$right2" = "$prev_right2" ]; then
74 echo ${prefix}${right1}