@@ -10,13 +10,13 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
1111# ---------------------------------------------------------------------------
1212# determine_pdf_needs – decide if PDF generation is required for a course.
13- # Sets the global `needs_pdfs` variable (true/false).
13+ # Sets the caller-visible variable `needs_pdfs` to "true" or "false".
14+ # Must be called from a context where `needs_pdfs` is already declared.
1415# ---------------------------------------------------------------------------
1516determine_pdf_needs () {
1617 local course=" $1 "
1718 local yaml_file=" ${course} .yml"
1819 local manifest=" .cache/${course} _upstream_pdfs"
19- needs_pdfs=false
2020
2121 # Try to download upstream PDFs (creates/updates the manifest)
2222 if bash " $SCRIPT_DIR /download_upstream_pdfs.sh" " $course " ; then
@@ -51,9 +51,11 @@ determine_pdf_needs() {
5151
5252# ---------------------------------------------------------------------------
5353# run_liaex – run the liaex command for a given course.
54+ # $1: course name $2: "true" if PDF generation is needed, "false" otherwise
5455# ---------------------------------------------------------------------------
5556run_liaex () {
5657 local course=" $1 "
58+ local needs_pdfs=" $2 "
5759 local yaml_file=" ${course} .yml"
5860
5961 case " $course " in
@@ -107,13 +109,14 @@ generate_course() {
107109
108110 echo " Generating $html_file from $yaml_file ..."
109111
110- # Determine whether PDF generation is needed (skipped for index)
112+ # Initialize needs_pdfs; determine_pdf_needs() will update it if applicable.
113+ # Not declared local so that determine_pdf_needs can write to the same variable.
111114 needs_pdfs=false
112115 if [ " $course " != " index" ]; then
113116 determine_pdf_needs " $course "
114117 fi
115118
116- run_liaex " $course "
119+ run_liaex " $course " " $needs_pdfs "
117120
118121 if [ -f " $html_file " ]; then
119122 echo " ✅ Successfully generated $html_file "
0 commit comments