From e784dc571becea2f1e7348b3b5c965af47022d82 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Tue, 14 Jun 2022 09:31:30 -0400 Subject: [PATCH] Make it so upgrade_system does not treat exit code 2 from fwupdmgr as an actual bad exit code --- .../dot_zshrc.d/executable_upgrade_system.sh | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/chezmoi/dot_zshrc.d/executable_upgrade_system.sh b/chezmoi/dot_zshrc.d/executable_upgrade_system.sh index 536299e..b162d32 100644 --- a/chezmoi/dot_zshrc.d/executable_upgrade_system.sh +++ b/chezmoi/dot_zshrc.d/executable_upgrade_system.sh @@ -42,8 +42,24 @@ upgrade_system() { fi if command -v fwupdmgr &> /dev/null; then - fwupdmgr refresh - fwupdmgr upgrade + ( + # 2 is a valid exit code for the fwupdmgr where + # the operation was successful but did not require + # action + set +e + + fwupdmgr refresh + STATUS=$? + if [ $STATUS -ne 0 ] && [ $STATUS -ne 2 ]; then + exit $STATUS + fi + + fwupdmgr upgrade + STATUS=$? + if [ $STATUS -ne 0 ] && [ $STATUS -ne 2 ]; then + exit $STATUS + fi + ) fi ) }