Behave nicely when the found readlink does not understand '-f'

Instead of just crashing when the found readlink does not understand
'-f', fall back to the pre ac887f310f
behaviour and print an error message if we fail to find
hg-fast-export.py.
This commit is contained in:
Frej Drejhammar
2017-06-05 18:41:44 +02:00
parent c252e6748e
commit 02bb982dd9

View File

@@ -7,7 +7,18 @@ READLINK="readlink"
if command -v greadlink > /dev/null; then
READLINK="greadlink" # Prefer greadlink over readlink
fi
ROOT="$(dirname "$($READLINK -f "$(which "$0")")")"
if ! $READLINK -f "$(which "$0")" >& /dev/null; then
ROOT="$(dirname "$(which "$0")")"
if [ ! -f "$ROOT/hg-fast-export.py" ] ; then
echo "hg-fast-exports requires a readlink implementation which knows" \
" how to canonicalize paths in order to be called via a symlink."
exit 1
fi
else
ROOT="$(dirname "$($READLINK -f "$(which "$0")")")"
fi
REPO=""
PFX="hg2git"
SFX_MAPPING="mapping"