* Paul Wise <p...@debian.org>, 2019-03-15, 12:56:
I decided to just check if the arguments are integers, attached the patch.

I like the idea, but how about the attached patch instead?

It's less repetitive, the diff is smaller, and it's hopefully slightly easier to understand.

--
Jakub Wilk
diff --git a/debian/dump b/debian/dump
index e8fc3fd..0492ac4 100644
--- a/debian/dump
+++ b/debian/dump
@@ -28,15 +28,22 @@ if [ "$(id -u)" != "0" ]; then
 	exit 1
 fi
 
-# Check how many arguments the kernel sent us.
-if [ $# -eq 2 ] ; then
+# Check how many numeric arguments the kernel sent us.
+numargs=0
+for arg; do
+	case "$1" in
+		(*[!0-9]*|'') break;;
+		(*) numargs=$((numargs + 1));;
+	esac
+done
+if [ $numargs -eq 1 ] ; then
 	# Awww, old kernel that does not support %d
 	# Cannot set the core file owner safely, use root
 	# See v3.6-6800-g12a2b4b in linux.git for more info
 	uid="$1"
 	core="$2"
 	owner="0"
-elif [ $# -eq 3 ] ; then
+elif [ $numargs -eq 2 ] ; then
 	# Yay! A kernel that does support %d
 	uid="$2"
 	core="$3"

Reply via email to