dracut-functions: remove double slashes, for symlink conversion

remove double slashes for symlink conversion from absolute to relative
master
Harald Hoyer 2011-07-25 14:28:55 +02:00
parent 6f09acf855
commit 626d9eba9c
1 changed files with 11 additions and 3 deletions

View File

@ -82,6 +82,13 @@ print_vars() {
done done
} }


normalize_path() {
p=$1
while [[ ${p#*//*} != $p ]]; do
p=${p/\/\///}
done
echo $p
}


convert_abs_rel() { convert_abs_rel() {
local __current __absolute __abssize __cursize __i __level __newpath local __current __absolute __abssize __cursize __i __level __newpath
@ -92,11 +99,12 @@ convert_abs_rel() {
echo "." echo "."
return return
fi fi

__current=$(normalize_path "$1")
__absolute=$(normalize_path "$2")
IFS="/" IFS="/"


__current=($1) __current=($__current)
__absolute=($2) __absolute=($__absolute)


__abssize=${#__absolute[@]} __abssize=${#__absolute[@]}
__cursize=${#__current[@]} __cursize=${#__current[@]}