pvscheck: Make realdir work with nonexistent directories

This commit is contained in:
ZyX
2018-04-02 00:07:05 +03:00
parent 98e7112390
commit 7eceac218e

View File

@@ -302,8 +302,16 @@ create_compile_commands() {(
# realpath is not available in Ubuntu trusty yet.
realdir() {(
local dir="$1"
cd "$dir"
printf '%s\n' "$PWD"
local add=""
while ! cd "$dir" 2>/dev/null ; do
add="${dir##*/}/$add"
local new_dir="${dir%/*}"
if test "$new_dir" = "$dir" ; then
return 1
fi
dir="$new_dir"
done
printf '%s\n' "$PWD/$add"
)}
patch_sources() {(