diff options
| author | Robert Günzler <r@gnzler.io> | 2021-06-04 12:21:39 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-06-04 12:21:39 +0200 |
| commit | da4cb088f783fd2c16a53c51c2fdf5d2b58080c8 (patch) | |
| tree | 8569b5017c424aeaab460c9e26b59fc41979c49d /bin | |
| parent | 67b658bc156087a7a007e3e4759037620c400d8c (diff) | |
bin/latexmk: provide realpath implementation
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/latexmk | 16 |
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" |