From da4cb088f783fd2c16a53c51c2fdf5d2b58080c8 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Fri, 4 Jun 2021 12:21:39 +0200 Subject: bin/latexmk: provide realpath implementation --- bin/latexmk | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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" -- cgit 1.4.1