From bbd52311adeeab956f14e8e0e47b2285bab50603 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 8 Dec 2022 19:31:34 +0100 Subject: [PATCH] mxproxmox: Remove trailing white space from backup-list lines Remove trailing whitespace from lines read from backup-list. If we keep trailing whitespace, the following split will keep the whitespace in $opt_limit. This is later checked with `if defined($limit)` , which is true. Still, the empty string will evaluate numerically to zero (with a warning). A limit zero is not what we want here. From `perldoc -f split`: When assigning to a list, if LIMIT is omitted, or zero, Perl supplies a LIMIT one larger than the number of variables in the list, to avoid unnecessary work This has this surprising effect: DB<1> x split " ","a " 0 'a' DB<2> @a = split " ","a " DB<3> x @s empty array DB<4> x @a 0 'a' DB<5> ($a, $b) = split " ","a " DB<6> x ($a, $b) 0 'a' 1 '' DB<7> --- mxproxmox/mxproxmox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mxproxmox/mxproxmox b/mxproxmox/mxproxmox index dc3cf0a..49f9bf8 100755 --- a/mxproxmox/mxproxmox +++ b/mxproxmox/mxproxmox @@ -199,7 +199,7 @@ sub read_backup_list { open my $in, '<', '/etc/mxproxmox/backup-list.dat' or die "/etc/mxproxmox/backup-list.dat: $!\n"; while (<$in>) { chomp; - s/#.*//; + s/\s*#.*//; /\S/ or next; my ($project, $opt_limit) = split " "; $INCLUDE{$project} = $opt_limit;