mirror of https://github.com/digint/btrbk
btrbk: use substitutions in printf
Avoid possible interpreted sequence from values (e.g. from FILE).pull/504/merge
parent
b800d1bb10
commit
f9c7a47b6a
6
btrbk
6
btrbk
|
@ -2092,14 +2092,16 @@ sub system_write_raw_info($$;@)
|
|||
|
||||
# sort by %raw_info_sort, then by key
|
||||
my @line = $append ? () : ("#btrbk-v$VERSION", "# Do not edit this file");
|
||||
my @subst;
|
||||
push @line, '#t=' . time;
|
||||
foreach(sort { (($raw_info_sort{$a} // 99) <=> ($raw_info_sort{$b} // 99)) || ($a cmp $b) } keys %$raw_info) {
|
||||
push @line, ($_ . '=' . $raw_info->{$_});
|
||||
push @line, ($_ . '=%s');
|
||||
push @subst, $raw_info->{$_};
|
||||
}
|
||||
|
||||
DEBUG "Writing (" . ($append ? "append:" . join(",", keys %$raw_info) : "create") . ") raw info file: $info_file";
|
||||
my $ret = run_cmd(
|
||||
{ cmd => [ 'printf', quoteshell(join('\n', @line) . '\n') ] },
|
||||
{ cmd => [ 'printf', quoteshell(join('\n', @line, "")), map quoteshell($_), @subst ] },
|
||||
{ ($append ? "append_to_file" : "redirect_to_file") => { unsafe => $info_file },
|
||||
rsh => vinfo_rsh($vol),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue