summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-06-04 12:21:39 +0200
committerRobert Günzler <r@gnzler.io>2021-06-04 12:21:39 +0200
commitda4cb088f783fd2c16a53c51c2fdf5d2b58080c8 (patch)
tree8569b5017c424aeaab460c9e26b59fc41979c49d /bin
parent67b658bc156087a7a007e3e4759037620c400d8c (diff)
bin/latexmk: provide realpath implementation
Diffstat (limited to 'bin')
-rwxr-xr-xbin/latexmk16
1 files changed, 15 insertions, 1 deletions
diff --git a/bin/latexmk b/bin/latexmk
index 79d497e..520fe20 100755
--- a/bin/latexmk
+++ b/bin/latexmk
@@ -26,8 +26,22 @@ while getopts 1Rnh opt; do
 done
 shift $((OPTIND - 1))
 
+# http://stackoverflow.com/a/18443300/441757
+_realpath() {
+	OURPWD=$PWD
+	cd "$(dirname "$1")"
+	LINK=$(readlink "$(basename "$1")")
+	while [ "$LINK" ]; do
+		cd "$(dirname "$LINK")"
+		LINK=$(readlink "$(basename "$1")")
+	done
+	REALPATH="$PWD/$(basename "$1")"
+	cd "$OURPWD"
+	echo "$REALPATH"
+}
+
 if [ -n "${reexec}" ]; then
-	pdf=$(realpath "$(printf "%s" "$1" | sed 's/\.tex/\.pdf/')")
+	pdf=$(_realpath "$(printf "%s" "$1" | sed 's/\.tex/\.pdf/')")
 	log() {
 		if [ -n "${nocolor}" ]; then
 			printf "%s!==>%s %s\n" "$(tput setaf 2)" "$(tput sgr0)" "$1"