From 779de00952b8cf03a3a34efe9c5ca0f287576546 Mon Sep 17 00:00:00 2001 From: merakor Date: Tue, 10 Aug 2021 23:12:37 +0000 Subject: fix CPT_COMPRESS if faulty variable is set FossilOrigin-Name: cea141d938e78239f6ec5c90457d40311797a712f87d0a001839b2e9b8b4e142 --- src/cpt-lib.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index a882594..abf5bdf 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -2233,8 +2233,13 @@ create_cache() { # do nothing on a normal system. mkdir -p "$CPT_ROOT/" 2>/dev/null ||: - # Set a value for CPT_COMPRESS if it isn't set. - : "${CPT_COMPRESS:=gz}" + # Set the default compression to gzip, and warn the user if the value is + # invalid. + case ${CPT_COMPRESS:=gz} in + bz2|gz|xz|zst|lz) ;; + *) warn "'$CPT_COMPRESS' is not a valid CPT_COMPRESS value, falling back to 'gz'" + CPT_COMPRESS=gz + esac # Set colors if they are to be enabled. # shellcheck disable=2034 -- cgit v1.2.3