From 02bb982dd902fe12f13aa17c4aad940af4ea28ae Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Mon, 5 Jun 2017 18:41:44 +0200 Subject: [PATCH] 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 ac887f310f8bfddf19e647f54d9f5cd6bfd1e64c behaviour and print an error message if we fail to find hg-fast-export.py. --- hg-fast-export.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hg-fast-export.sh b/hg-fast-export.sh index 1117cbd..b291296 100755 --- a/hg-fast-export.sh +++ b/hg-fast-export.sh @@ -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" -- 2.11.4.GIT