From b76b3ca4ca912e1dfd0cbe677a5343789909dd53 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 8 Feb 2020 20:23:55 +0100 Subject: [PATCH] Fix compile script Fixed compile script to not use ifinstalled anymore. HACK Fixed compile script to correctly pass through output targets to RMarkdown, through the implementation is very rough currently. It will look for additional arguments passed through and run RMarkdown rendering once for each target. It would presumably be faster (and at the very least more elegant) to pass all arguments through at once, but I am not sure how to pass arguments through shell surrounded with quotes. --- scripts/.local/bin/compile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/scripts/.local/bin/compile b/scripts/.local/bin/compile index 1dd0e5d..4a38bc7 100755 --- a/scripts/.local/bin/compile +++ b/scripts/.local/bin/compile @@ -11,8 +11,13 @@ # Expects the file to compile as first argument. # Desired output format(s) can be specified in optional arguments following. -file=$(readlink -f "$1") -printf "file: %s\n" "$file" +file=$1 +if [ ! -f "$file" ]; then + echo "File does not exist." + exit 1 +else + printf "file: %s\n" "$file" +fi if [ "$#" -gt 1 ]; then shift @@ -25,9 +30,9 @@ base="${file%.*}" cd "$dir" || exit textype() { - if (sed 5q "$file" | grep -i -q 'xelatex') && ifinstalled xelatex; then + if (sed 5q "$file" | grep -i -q 'xelatex') && exist xelatex; then command="xelatex" - elif ifinstalled pdflatex; then + elif exist pdflatex; then command="pdflatex" fi $command --output-directory="$dir" "$base" && @@ -38,10 +43,16 @@ textype() { } sendtoRmd() { - # v removed for too much magic that can break; simply input pdf_document if you want it - # formats=$(echo "$formats" | perl -pe 's/([\w-]+)(?