From 6633eac3554ec02599f76576a1938a4ca3852d6a Mon Sep 17 00:00:00 2001 From: Arnaud Rebillout Date: Wed, 1 Jun 2022 14:49:43 +0700 Subject: [PATCH] Nitpicks in maintainer scripts There is no need for quotes in variables assignments since dash 0.5.11 or newer, cf [1]. The keyword 'local' is supported by dash, so let's use it consistently, cf [2]. It seems that we want to quote filenames, so let's try to do it consistently, even though at the moment spaces in filenames are not supported anyway, due to the loops 'for f in $FILES_TO_DIVERT'. [1]: https://unix.stackexchange.com/a/97569/105794 [2]: https://stackoverflow.com/a/18600920 --- debian/kali-themes.postinst | 17 +++++++++-------- debian/kali-themes.postrm | 2 +- debian/kali-themes.preinst | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/debian/kali-themes.postinst b/debian/kali-themes.postinst index d98e6cd9..20cafee9 100644 --- a/debian/kali-themes.postinst +++ b/debian/kali-themes.postinst @@ -35,8 +35,8 @@ FILES_TO_DIVERT=" install_all() { local opt=$1 - for file in $FILES_TO_DIVERT - do + local file= + for file in $FILES_TO_DIVERT; do install_config_file "$file" "$opt" done } @@ -45,18 +45,19 @@ install_config_file() { local file=$1 local opt=$2 local orig_file="/usr/share/kali-themes$file" - if [ "$opt" = "force" ] || ([ ! -e $file ] && [ -e $orig_file ]); then + if [ "$opt" = "force" ] || ([ ! -e "$file" ] && [ -e "$orig_file" ]); then echo "Installing $orig_file as $file" - mkdir -p $(dirname $file) - cp $orig_file $file + mkdir -p "$(dirname "$file")" + cp "$orig_file" "$file" fi } remove_config_file() { - rm -f $1 + local file=$1 + rm -f "$file" dpkg-divert --rename --package kali-themes \ - --divert "$1.original" \ - --remove "$1" + --divert "$file.original" \ + --remove "$file" } if [ "$1" = "configure" ]; then diff --git a/debian/kali-themes.postrm b/debian/kali-themes.postrm index 3b15794b..47434abc 100644 --- a/debian/kali-themes.postrm +++ b/debian/kali-themes.postrm @@ -34,7 +34,7 @@ FILES_TO_DIVERT=" " # END FILES_TO_DIVERT drop_diversion() { - local file="$1" + local file=$1 dpkg-divert --rename --package kali-themes \ --divert "$file.original" \ --remove "$file" diff --git a/debian/kali-themes.preinst b/debian/kali-themes.preinst index 0ae5992d..7b719738 100644 --- a/debian/kali-themes.preinst +++ b/debian/kali-themes.preinst @@ -34,8 +34,8 @@ FILES_TO_DIVERT=" " # END FILES_TO_DIVERT setup_diversion() { - local file="$1" - divert_opts="--rename" + local file=$1 + local divert_opts="--rename" if [ -e "$file" ]; then if dpkg --search "$file" >/dev/null 2>&1; then # Keep original file to avoid spurious dpkg prompt