Subject: bug#599: initscripts: typo in /etc/init.d/sendsigs (easy fix)

From: Jerome BENOIT <[email-masked]>
Date: Sun, 8 Aug 2021 14:36:57 +0200

Hello Mark, thanks for pointing me to /usr/share/doc/initscripts/README.Debian .
I am sorry I could not find the commit you reference to.

Indeed the current script fulfills the policy in the above README.Debian .

I would however make the minor change in the first loop [ -e $omitfile ] to [ -f $omitfile ] to make clearer
that a file is expected (see patch 599_bugs_devuan_org-sendsigs-filetest.patch )

Having said that I think that making loops over one element is rather confusing
and it deserves some explanation if it must be kept it that way
(see patch 599_bugs_devuan_org-sendsigs-lessconfusing.patch ).

Cheers,
Jerome

-- 
Jerome BENOIT | calculus+at-rezozer^dot*net
https://qa.debian.org/developer.php?login=[email-masked]
AE28 AE15 710D FF1D 87E5  A762 3F92 19A6 7F36 C68B
--- sendsigs.dpkg-dist-original	2019-02-26 17:59:47.000000000 +0100
+++ sendsigs	2021-08-08 14:03:35.860634425 +0200
@@ -28,7 +28,7 @@
 	OMITPIDS=
 
 	for omitfile in /run/sendsigs.omit; do
-		if [ -e $omitfile ]; then
+		if [ -f $omitfile ]; then
 			for pid in $(cat $omitfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
 			done
--- sendsigs.dpkg-dist-original	2019-02-26 17:59:47.000000000 +0100
+++ sendsigs	2021-08-08 14:20:43.607818183 +0200
@@ -27,27 +27,25 @@
 do_stop () {
 	OMITPIDS=
 
-	for omitfile in /run/sendsigs.omit; do
-		if [ -e $omitfile ]; then
-			for pid in $(cat $omitfile); do
-				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
-			done
-		fi
-	done
+	omitfile="/run/sendsigs.omit"
+	if [ -f "${omitfile}" ]; then
+		for pid in $(cat "${omitfile}"); do
+			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+		done
+	fi
 
 	# Load sendsigs.omit.d/packagename files too, to make it
 	# possible for scripts that need to modify the list of pids at
 	# run time without race conditions.
-	for omitdir in /run/sendsigs.omit.d; do
-		if [ -d "${omitdir}" ]; then
-			for pidfile in "${omitdir}/"*; do
-				[ -f "$pidfile" ] || continue
-				for pid in $(cat $pidfile); do
-					OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
-				done
+	omitdir="/run/sendsigs.omit.d"
+	if [ -d "${omitdir}" ]; then
+		for pidfile in "${omitdir}/"*; do
+			[ -f "${pidfile}" ] || continue
+			for pid in $(cat "${pidfile}"); do
+				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
 			done
-		fi
-	done
+		done
+	fi
 
 	# Upstart jobs have their own "stop on" clauses that sends
 	# SIGTERM/SIGKILL just like this, so if they're still running,