From 41ffbb640d85aa59b7cce0c90572f4ea68ad6bd4 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 19:24:43 +0100 Subject: [PATCH] xbmk: stricter handling of files on while loops i overlooked these! Signed-off-by: Leah Rowe --- include/lib.sh | 4 ++-- include/tree.sh | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/lib.sh b/include/lib.sh index 6c83179..025db88 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -106,9 +106,9 @@ fx_() dx_() { - [ -f "$2" ] && while read -r fx; do + [ ! -f "$2" ] || while read -r fx; do $1 "$fx" || return 1 - done < "$2"; : + done < "$2" || err "dx_ $*: cannot read '$2'"; : } x_() diff --git a/include/tree.sh b/include/tree.sh index 25d4732..9dccf85 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -332,8 +332,9 @@ check_makefile() copy_elf() { - [ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do + [ -f "$listfile" ] && x_ mkdir -p "$dest_dir" + [ ! -f "$listfile" ] || while read -r f; do [ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir" - done < "$listfile" + done < "$listfile" || err "copy_elf $*: cannot read '$listfile'" x_ make clean -C "$srcdir" $cleanargs }