Subject: | -InterPolateEnv and environment variables containing multiple backslahes |
Hello,
It seems that environment variables having backslashes may cause trouble, please c.f. attachment.
The output is:
1..3
ok 1 - Got x from environment
ok 2 - Got \x from environment
not ok 3 - Got \\x from environment
# Failed test 'Got \\x from environment'
# at C:\temp\config_general.pl line 8.
# got: '\x'
# expected: '\\x'
# Looks like you failed 1 test of 3.
Typical use case is on Windows, where a path is stored in an environment variable, that path being UNC.
Subject: | config_general.pl |
#!env perl
use strict;
use Config::General;
use Test::More tests => 3;
print "$Config::General::VERSION\n";
cmp_ok(testenvvar('x'), 'eq', 'x', "Got x from environment");
cmp_ok(testenvvar('\\x'), 'eq', '\\x', "Got \\x from environment");
cmp_ok(testenvvar('\\\\x'), 'eq', '\\\\x', "Got \\\\x from environment");
sub testenvvar {
my ($value) = @_;
local $ENV{_TESTENVVAR_} = $value;
my %h = Config::General->new(-String => "_TESTENVVAR_\t\$_TESTENVVAR_", -InterPolateEnv => 1)->getall;
return $h{_TESTENVVAR_};
}