From d250fbb3d60afa7092c39f4a827ebaec779164b8 Mon Sep 17 00:00:00 2001 From: Jim Barlow Date: Thu, 25 Sep 2014 03:11:27 -0700 Subject: [PATCH 1/2] Fix call to readlink on OS X readlink -f is a GNU coreutils extension, so not available on OS X and other platforms. --- OCRmyPDF.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OCRmyPDF.sh b/OCRmyPDF.sh index 2b831153..badea83b 100755 --- a/OCRmyPDF.sh +++ b/OCRmyPDF.sh @@ -3,6 +3,13 @@ # Copyright (c) 2013-14: fritz-hh from Github (https://github.com/fritz-hh) ############################################################################## +# Darwin/OS X has not evolved a proper readlink yet +if [ $(uname) == "Darwin" ]; then + function readlink() { + python -c 'import os,sys; print os.path.realpath(sys.argv[1])' "$2" + } +fi + # Import required scripts BASEPATH="$(dirname $(readlink -f $0))" . "$BASEPATH/src/config.sh" From 3f8a2d8d3ed18583b46ff7a5707ce7958b7d2ec5 Mon Sep 17 00:00:00 2001 From: Jim Barlow Date: Thu, 25 Sep 2014 13:47:35 -0700 Subject: [PATCH 2/2] Eliminate readlink entirely and do the same thing on all platforms --- OCRmyPDF.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/OCRmyPDF.sh b/OCRmyPDF.sh index badea83b..000a7259 100755 --- a/OCRmyPDF.sh +++ b/OCRmyPDF.sh @@ -3,15 +3,10 @@ # Copyright (c) 2013-14: fritz-hh from Github (https://github.com/fritz-hh) ############################################################################## -# Darwin/OS X has not evolved a proper readlink yet -if [ $(uname) == "Darwin" ]; then - function readlink() { - python -c 'import os,sys; print os.path.realpath(sys.argv[1])' "$2" - } -fi +# Determine real path of this script, following symlinks if present +BASEPATH="$(dirname $(python -c "import os; print os.path.realpath(\"$0\")"))" # Import required scripts -BASEPATH="$(dirname $(readlink -f $0))" . "$BASEPATH/src/config.sh" # Set variables corresponding to the input parameters