From d31ffb8cb06a87770e174e1f8268721171ba2f40 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sat, 18 Mar 2017 16:34:53 +0100 Subject: [PATCH] btrbk: allow trailing comments in btrbk.conf --- ChangeLog | 1 + btrbk | 4 ++-- doc/btrbk.conf.5 | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5df2b42..176f479 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ btrbk-current * Add "backend btrfs-progs-sudo" configuration option (close #115). * Show aggregate "size" and "used" for "usage" action (close #119). * Add "raw_target_split" configuration option (close #125). + * Allow trailing comments in btrbk.conf (close #129). * Bugfix: rate limiting must be done after compression (close #134). * raw_target_encrypt: Always set "gpg --no-random-seed-file": prevents creation of "~/.gnupg/random_seed" with slight perfomance diff --git a/btrbk b/btrbk index f4c81a0..790dae6 100755 --- a/btrbk +++ b/btrbk @@ -2902,14 +2902,14 @@ sub parse_config(@) open(FILE, '<', $file) or die $!; while () { chomp; - next if /^\s*#/; # ignore comments + s/#.*//; # remove comments + s/\s*$//; # remove trailing whitespace next if /^\s*$/; # ignore empty lines TRACE "config: parsing line $. with context=$cur->{CONTEXT}: \"$_\""; if(/^(\s*)([a-zA-Z_]+)\s+(.*)$/) { # NOTE: we do not perform checks on indentation! my ($indent, $key, $value) = (length($1), lc($2), $3); - $value =~ s/\s*$//; $cur = parse_config_line($file, $root, $cur, $key, $value); unless(defined($cur)) { # error, bail out diff --git a/doc/btrbk.conf.5 b/doc/btrbk.conf.5 index f721b6a..e7de78f 100644 --- a/doc/btrbk.conf.5 +++ b/doc/btrbk.conf.5 @@ -19,6 +19,9 @@ defined either globally or within a section. The options specified always apply to the last section encountered, superseding the values set in upper-level sections. This means that global options must be set before any sections are defined. +.PP +Blank lines are ignored. A hash character (#) starts a comment +extending until end of line. .SH SECTIONS .PP \fBvolume\fR | @@ -305,9 +308,6 @@ For convenience, it is also possible to set \fIbackend_local\fR or local or remote sources/targets (e.g. "backend_remote btrfs-progs-btrbk"). .RE -.PP -Lines that contain a hash character (#) in the first column are -treated as comments. .SH RETENTION POLICY btrbk uses separate retention policies for snapshots and backups, which are defined by the \fIsnapshot_preserve_min\fR,