Skip to content

Commit

Permalink
mxproxmox: Remove trailing white space from backup-list lines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
donald committed Dec 8, 2022
1 parent 4cb9474 commit bbd5231
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mxproxmox/mxproxmox
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bbd5231

Please sign in to comment.