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
This commit is contained in:
Arnaud Rebillout 2022-06-01 14:49:43 +07:00
parent f8e8487d44
commit 6633eac355
No known key found for this signature in database
GPG Key ID: E725E87914600216
3 changed files with 12 additions and 11 deletions

View File

@ -35,8 +35,8 @@ FILES_TO_DIVERT="
install_all() { install_all() {
local opt=$1 local opt=$1
for file in $FILES_TO_DIVERT local file=
do for file in $FILES_TO_DIVERT; do
install_config_file "$file" "$opt" install_config_file "$file" "$opt"
done done
} }
@ -45,18 +45,19 @@ install_config_file() {
local file=$1 local file=$1
local opt=$2 local opt=$2
local orig_file="/usr/share/kali-themes$file" 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" echo "Installing $orig_file as $file"
mkdir -p $(dirname $file) mkdir -p "$(dirname "$file")"
cp $orig_file $file cp "$orig_file" "$file"
fi fi
} }
remove_config_file() { remove_config_file() {
rm -f $1 local file=$1
rm -f "$file"
dpkg-divert --rename --package kali-themes \ dpkg-divert --rename --package kali-themes \
--divert "$1.original" \ --divert "$file.original" \
--remove "$1" --remove "$file"
} }
if [ "$1" = "configure" ]; then if [ "$1" = "configure" ]; then

View File

@ -34,7 +34,7 @@ FILES_TO_DIVERT="
" # END FILES_TO_DIVERT " # END FILES_TO_DIVERT
drop_diversion() { drop_diversion() {
local file="$1" local file=$1
dpkg-divert --rename --package kali-themes \ dpkg-divert --rename --package kali-themes \
--divert "$file.original" \ --divert "$file.original" \
--remove "$file" --remove "$file"

View File

@ -34,8 +34,8 @@ FILES_TO_DIVERT="
" # END FILES_TO_DIVERT " # END FILES_TO_DIVERT
setup_diversion() { setup_diversion() {
local file="$1" local file=$1
divert_opts="--rename" local divert_opts="--rename"
if [ -e "$file" ]; then if [ -e "$file" ]; then
if dpkg --search "$file" >/dev/null 2>&1; then if dpkg --search "$file" >/dev/null 2>&1; then
# Keep original file to avoid spurious dpkg prompt # Keep original file to avoid spurious dpkg prompt