add new flag AlwaysQuoteOutput for write quoting

This commit is contained in:
2025-01-07 10:36:02 +01:00
parent 35dc4c10c9
commit 3937d2423e
3 changed files with 20 additions and 4 deletions

View File

@@ -32,7 +32,7 @@ use Carp::Heavy;
use Carp;
use Exporter;
$Config::General::VERSION = "2.65";
$Config::General::VERSION = "2.66";
use base qw(Exporter);
our @EXPORT_OK = qw(ParseConfig SaveConfig SaveConfigString);
@@ -96,7 +96,8 @@ sub new {
NormalizeValue => 0,
Plug => {},
UseApacheIfDefine => 0,
Define => {}
Define => {},
AlwaysQuoteOutput => 0
};
# create the class instance
@@ -1424,7 +1425,7 @@ sub _write_scalar {
$line =~ s/([#\$\\\"])/\\$1/g;
}
if ($line =~ /\s/) {
if ($line =~ /^\s/ || $line =~ /\s$/ || $this->{AlwaysQuoteOutput}) {
# quote lines containing whitespace
$line = "\"$line\"";
}
@@ -2119,6 +2120,11 @@ Same as B<-NormalizeBlock> but applied on options only.
Same as B<-NormalizeBlock> but applied on values only.
=item B<-AlwaysQuoteOutput>
If set to true, then values containing whitespace will always quoted
when calling C<save_string()> or C<save_file()>.
=back