From 04ed19dc491361b26ec02bf2a1017e7c343891ae Mon Sep 17 00:00:00 2001 From: utensil Date: Wed, 9 Oct 2024 14:04:25 +0800 Subject: [PATCH] Run `shellcheck` and fix some shell issues --- build.sh | 12 ++++++------ justfile | 6 ++++++ lize.sh | 14 +++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index cdc5213..71e2a75 100755 --- a/build.sh +++ b/build.sh @@ -126,17 +126,17 @@ function build { } function lize { - ./lize.sh spin-0001 2>&1 > /dev/null + ./lize.sh spin-0001 > /dev/null 2>&1 show_lize_result spin-0001 - ./lize.sh hopf-0001 2>&1 > /dev/null + ./lize.sh hopf-0001 > /dev/null 2>&1 show_lize_result hopf-0001 - ./lize.sh ca-0001 2>&1 > /dev/null + ./lize.sh ca-0001 > /dev/null 2>&1 show_lize_result ca-0001 - ./lize.sh tt-0001 2>&1 > /dev/null + ./lize.sh tt-0001 > /dev/null 2>&1 show_lize_result tt-0001 - ./lize.sh uts-000C 2>&1 > /dev/null + ./lize.sh uts-000C > /dev/null 2>&1 show_lize_result uts-000C -# ./lize.sh uts-0001 2>&1 > /dev/null +# ./lize.sh uts-0001 > /dev/null 2>&1 # show_lize_result uts-0001 } diff --git a/justfile b/justfile index e89b3de..daba57d 100644 --- a/justfile +++ b/justfile @@ -62,5 +62,11 @@ envs: #!/usr/bin/env bash echo "PROJECT_ROOT: $PROJECT_ROOT" +install-shellcheck: + brew install shellcheck + +run-shellcheck: + shellcheck *.sh + # act: # ./act.sh diff --git a/lize.sh b/lize.sh index 96aaac0..149a6a1 100755 --- a/lize.sh +++ b/lize.sh @@ -19,7 +19,7 @@ TEX_FILE="$1.tex" AUX_FILE="$1.aux" PDF_FILE="$1.pdf" -rm build/$1.* 2>&1 >/dev/null || echo no files to clean +rm build/$1.* >/dev/null 2>&1 || echo no files to clean cp output/$XML_FILE build/$XML_FILE @@ -35,16 +35,16 @@ UNICOCE_LATEX=lualatex # if environment variable TEC is not set if [ -z "$TEC" ]; then echo "lize.sh| using $UNICOCE_LATEX" - $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE 2>&1 >/dev/null + $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE >/dev/null 2>&1 # https://tex.stackexchange.com/a/295524/75671 # biber $TEX_FILE # We should ignore bibtex errors if it's simply an empty .bib file - bibtex $AUX_FILE 2>&1 >/dev/null || echo "lize.sh| Ignoring bibtex error" - $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE 2>&1 >/dev/null - $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE 2>&1 >/dev/null + bibtex $AUX_FILE >/dev/null 2>&1 || echo "lize.sh| Ignoring bibtex error" + $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE >/dev/null 2>&1 + $UNICOCE_LATEX -halt-on-error -interaction=nonstopmode --shell-escape $TEX_FILE >/dev/null 2>&1 else echo "lize.sh| using tectonic" - tectonic -Z shell-escape-cwd=`pwd` --keep-intermediates --keep-logs --outdir `pwd` $TEX_FILE 2>&1 >/dev/null + tectonic -Z shell-escape-cwd=`pwd` --keep-intermediates --keep-logs --outdir `pwd` $TEX_FILEi >/dev/null 2>&1 fi cd .. @@ -55,4 +55,4 @@ echo "lize.sh| Open build/$1.log to see the log." echo "lize.sh| Open build/$TEX_FILE to see the LaTeX source." echo "lize.sh| Open output/$PDF_FILE to see the result." -# use ./lize.sh uts-0001 2>&1|grep lize to see a short output \ No newline at end of file +# use ./lize.sh uts-0001 2>&1|grep lize to see a short output