From 209b8c92f0c44644d0476349b4a65f4b9ad942de Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 9 Apr 2021 19:49:32 +0200 Subject: [PATCH] test: use quotes where necessary to avoid possible word splitting. [dtardon: Dropped changes to other files.] (cherry picked from commit 38825267983a439f2cf8375463b1edc9ca2d3323) Related: #2156620 --- test/TEST-15-DROPIN/test-dropin.sh | 44 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh index 30f1e84954..a197989f72 100755 --- a/test/TEST-15-DROPIN/test-dropin.sh +++ b/test/TEST-15-DROPIN/test-dropin.sh @@ -4,51 +4,53 @@ set -e set -x _clear_service () { - systemctl stop $1.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} - if [[ $1 == *@ ]]; then - systemctl stop $1*.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1*.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1*.service.{wants,requires} + local SERVICE_NAME="${1:?_clear_service: missing argument}" + systemctl stop "$SERVICE_NAME.service" 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.d + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME".service.{wants,requires} + if [[ $SERVICE_NAME == *@ ]]; then + systemctl stop "$SERVICE_NAME"*.service 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.d + rm -fr /{etc,run,usr/lib}/systemd/system/"$SERVICE_NAME"*.service.{wants,requires} fi } clear_services () { - for u in $*; do - _clear_service $u + for u in "$@"; do + _clear_service "$u" done systemctl daemon-reload } create_service () { - clear_services $1 + local SERVICE_NAME="${1:?create_service: missing argument}" + clear_services "$SERVICE_NAME" - cat >/etc/systemd/system/$1.service</etc/systemd/system/"$SERVICE_NAME".service <