aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-08-10 23:12:37 +0000
committermerakor <cem@ckyln.com>2021-08-10 23:12:37 +0000
commit779de00952b8cf03a3a34efe9c5ca0f287576546 (patch)
treec84234411701c831482a39bb05e7420f55da42d8 /src
parent296796280f670a5da9aee42cc86f127e6a48e602 (diff)
downloadcpt-779de00952b8cf03a3a34efe9c5ca0f287576546.tar.gz
fix CPT_COMPRESS if faulty variable is set
FossilOrigin-Name: cea141d938e78239f6ec5c90457d40311797a712f87d0a001839b2e9b8b4e142
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in9
1 files 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