From f31dcd88f3074bbe831d1974754650f49ddf858b Mon Sep 17 00:00:00 2001 From: Plectranthus <37979371+Plectranthus-fg@users.noreply.github.com> Date: Wed, 8 Dec 2021 09:48:33 +0800 Subject: [PATCH] lib/builtins.sh: test file existence before patching Skip non-existent patches in ab_*_ patches. --- lib/builtins.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/builtins.sh b/lib/builtins.sh index a7f89be..4fc8e08 100644 --- a/lib/builtins.sh +++ b/lib/builtins.sh @@ -7,15 +7,19 @@ RPATCHFLAGS="-Rp1 -t" ab_apply_patches() { for i in "$@"; do - abinfo "Applying patch $i ..." - patch $PATCHFLAGS -i "$i" || abdie "Applying patch $i failed" + if [[ -e $i ]];then + abinfo "Applying patch $i ..." + patch $PATCHFLAGS -i "$i" || abdie "Applying patch $i failed" + fi done } ab_reverse_patches() { for i in "$@"; do - abinfo "Reverting patch $i ..." - patch $RPATCHFLAGS -i "$i" || abdie "Reverting patch $i failed" + if [[ -e $i ]];then + abinfo "Reverting patch $i ..." + patch $RPATCHFLAGS -i "$i" || abdie "Reverting patch $i failed" + fi done } @@ -30,4 +34,4 @@ ab_match_arch() { abinfo "Architecture '$ABHOST' mismatches '$1': taking false branch." return 1 fi -} +} \ No newline at end of file