From 79111b5b14b04d33fa67536318a9b8b3a61086e3 Mon Sep 17 00:00:00 2001 From: Thibaud Lasguignes Date: Mon, 6 Jan 2025 12:47:43 +0100 Subject: [PATCH 1/2] make document launcher - improve list to include files with space. moreover, add list of extensions to ease modifications. --- make_document_launcher.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/make_document_launcher.sh b/make_document_launcher.sh index 3ec0b56..e0738f3 100755 --- a/make_document_launcher.sh +++ b/make_document_launcher.sh @@ -20,29 +20,35 @@ do echo "##############################################################################################################" echo "########################################### Start Compilation ################################################" echo "##############################################################################################################" - list_files=$(find src/ -name '*.tex') - list_files+=" "$(find src/ -name '*.bib') - list_files+=" "$(find src/ -name '*.cls') - list_files+=" "$(find src/ -name '*.sty') - list_files+=" "$(find src/ -name '*.png') - list_files+=" "$(find src/ -name '*.jpg') - list_files+=" "$(find src/ -name '*.jpeg') - list_files+=" "$(find src/ -name '*.pdf') - list_files+=" "$(find src/ -name '*.eps') - list_files+=" "$(find src/ -name '*.svg') - if [[ -z "${list_files// }" ]]; then + + list_files=() + + # list of extensions to watch + extensions=("tex" "bib" "cls" "sty" "png" "jpg" "jpeg" "pdf" "eps" "svg") + + for ext in "${extensions[@]}"; do + while IFS= read -r -d '' file; do + list_files+=("$file") + done < <(find src/ -name "*.$ext" -print0) + done + + if [[ ${#list_files[@]} -eq 0 ]]; then # list empty - # echo "no files to notify, waiting 1s..." + echo "no files to watch, waiting 1s..." sleep 1 else # list not empty - echo "the files to watch are "$list_files - inotifywait -e modify $list_files + echo "the files to watch are: " + printf "%s\n" "${list_files[@]}" + + inotifywait -e modify "${list_files[@]}" + if [ $# -eq 0 ]; then make fast else make "$@" fi + sleep 0.1 fi done From 27aa7763569d7123cc4d31d7e8b65f16324be510 Mon Sep 17 00:00:00 2001 From: Thibaud Lasguignes Date: Mon, 6 Jan 2025 14:00:13 +0100 Subject: [PATCH 2/2] apply the change for space in filenames to make_figure too --- make_figure_launcher.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/make_figure_launcher.sh b/make_figure_launcher.sh index 3eb61b5..01fd952 100755 --- a/make_figure_launcher.sh +++ b/make_figure_launcher.sh @@ -19,16 +19,21 @@ do list_folders=$(find . -name "tikz" -type d) list_files=() for folder in $list_folders; do - list_files+=$(find $folder -name '*.tex') + while IFS= read -r -d '' file; do + list_files+=("$file") + done < <(find src/ -name "*.tex" -print0) done - if [[ -z "${list_files// }" ]]; then + if [[ ${#list_files[@]} -eq 0 ]]; then # list empty - # echo "no files to notify, waiting 1s..." + echo "no files to watch, waiting 1s..." sleep 1 else # list not empty - echo "the files to watch are "$list_files - inotifywait -e modify $list_files + echo "the files to watch are: " + printf "%s\n" "${list_files[@]}" + + inotifywait -e modify "${list_files[@]}" + make figures sleep 0.1 fi