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. # realpath is not available in Ubuntu trusty yet.
realdir() {( realdir() {(
local dir="$1" local dir="$1"
cd "$dir" local add=""
printf '%s\n' "$PWD" 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() {( patch_sources() {(