From e32e1ffbc2c802aef175144bb9546131632a20b9 Mon Sep 17 00:00:00 2001 From: DTB Date: Mon, 20 May 2024 11:37:02 -0600 Subject: [PATCH] preload: replace if/elif chain with case --- preload | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/preload b/preload index 765925e6e1..69b2c2d14d 100755 --- a/preload +++ b/preload @@ -260,21 +260,15 @@ $prefix/$app "\("$status"\)" $line"$'\n' fi - #determine status text-color for app name (green for installed, red for uninstalled, yellow for corrupted) - if [ -z "$status" ];then - add+="$text_color" - elif [ "$status" == installed ];then - add+="#00AA00" - elif [ "$status" == uninstalled ];then - add+="#CC3333" - elif [ "$status" == corrupted ];then - add+="#888800" - elif [ "$status" == disabled ];then - add+="#FF0000" - else - # fallback incase unexpected status - add+="$text_color" - fi + # Determine status text color for app name. + case "$status" in + installed) add+="#00AA00" ;; # green + uninstalled) add+="#CC3333" ;; # light red + corrupted) add+="#888800" ;; # yellow + disabled) add+="#FF0000" ;; # deep red + *) add+="$text_color" ;; + esac + #output finished app lines add="${add//[&]/&}" echo "$add"