Skip to content

Commit a870c93

Browse files
Copilotvgoehler
andauthored
fix: ensure lesson_count/LESSON_COUNT is always a single integer
Use `$(grep ...) || var=0` assignment pattern so that: - zero matches (grep exits 1, prints "0"): || branch sets var=0 correctly - missing file (grep exits 2, prints nothing): || branch sets var=0 - matches found (grep exits 0, prints N): var=N, || branch skipped This avoids the "0\n0" double-value produced by the old `|| echo 0` pattern when grep prints "0" and then the fallback also prints "0". Agent-Logs-Url: https://github.com/TUBAF-IfI-LiaScript/TUBAF-IfI-LiaScript.github.io/sessions/5c24d93a-7262-46db-93d4-c7e22d69854c Co-authored-by: vgoehler <1705385+vgoehler@users.noreply.github.com>
1 parent 6fecc10 commit a870c93

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ download-pdfs-%:
5151
@if [ -n "$(filter $*,$(PDF_COURSES))" ]; then \
5252
mkdir -p .cache; \
5353
[ -x scripts/download_upstream_pdfs.sh ] || chmod +x scripts/download_upstream_pdfs.sh; \
54-
LESSON_COUNT=$$(grep -c '^[[:space:]]*- url:' "$*.yml" 2>/dev/null || true); \
54+
LESSON_COUNT=$$(grep -c '^[[:space:]]*- url:' "$*.yml" 2>/dev/null) || LESSON_COUNT=0; \
5555
if bash scripts/download_upstream_pdfs.sh "$*"; then \
5656
if [ -f ".cache/$*_upstream_pdfs" ]; then \
5757
UPSTREAM_COUNT=$$(wc -l < ".cache/$*_upstream_pdfs" | tr -d ' '); \

scripts/generate_courses.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ for course in "${course_list[@]}"; do
2929
# Try to download upstream PDFs (creates/updates the manifest)
3030
if bash "$SCRIPT_DIR/download_upstream_pdfs.sh" "$course"; then
3131
# Count lessons and compare with upstream PDF coverage
32-
lesson_count=$(grep -c '^[[:space:]]*- url:' "$yaml_file" 2>/dev/null || true)
32+
lesson_count=$(grep -c '^[[:space:]]*- url:' "$yaml_file" 2>/dev/null) || lesson_count=0
3333
if [ -f "$manifest" ]; then
3434
upstream_count=$(wc -l < "$manifest" | tr -d ' ')
3535
else

0 commit comments

Comments
 (0)