Skip Menu |

This queue is for tickets about the Config-General CPAN distribution.

Report information
The Basics
Id: 118840
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: MELEZHIK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bash/shell expansion/interpolation support
HI! Basically idea is to allow such an expression: user = $USER # will be equal to the value of $USER environment variable dir = ~/ok # will be equal to /home/$USER/ And so on ... It could be option of course, so user could enable/disable on his choice. What do you think? It'd be very useful. At least for me :)
There's alreay a flag for this: -InterPolateEnv => 1. However, there's no directory expansion, and I'm not going to add this, since this has nothing to do with config parsing. best, Tom
Subject: Re: [rt.cpan.org #118840] bash/shell expansion/interpolation support
Date: Fri, 18 Nov 2016 23:36:02 +0300
To: bug-Config-General [...] rt.cpan.org
From: Alexey Melezhik <melezhik [...] gmail.com>
Hi Tom! I mean bash/shell variables interpolation, not those you have under interpolation directly inside in configuration file May be my example was abit confused but what I need: export FOO='bar' Then in configuration file have: a = $FOO Resulted in a getting a value 'bar' Also tilda expansion; Say I am user with id=alex $ id alex And have a home directory at /home/alex Then if in config file I have: dir = ~/some-dir/ Which result that dir is getting /home/alex/some-dir/ value Does it make a sense? 2016-11-18 23:09 GMT+03:00 T. Linden via RT <bug-Config-General@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=118840 > > > There's alreay a flag for this: -InterPolateEnv => 1. However, there's no directory expansion, and I'm not going to add this, since this has nothing to do with config parsing. > > > best, > Tom
Hi, please read the documentation on the -InterPolateEnv flag. It imports environment variables into the scope of your config file - so, exactly what you want to do. However, tilde expansion has nothing to do with config files and it is unix specific. I understand your use-case, but I'm not going to add a feature for this into Config::General. But you can implement this yourself, refer to the "PARSER PLUGINS" section. best, Tom
Subject: Re: [rt.cpan.org #118840] bash/shell expansion/interpolation support
Date: Sat, 19 Nov 2016 00:32:20 +0300
To: bug-Config-General [...] rt.cpan.org
From: Alexey Melezhik <melezhik [...] gmail.com>
Thanks for explanation, Tom. Now I see. Regards. 2016-11-18 23:58 GMT+03:00 T. Linden via RT <bug-Config-General@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=118840 > > > Hi, > > please read the documentation on the -InterPolateEnv flag. It imports environment variables into the scope of your config file - so, exactly what you want to do. > > However, tilde expansion has nothing to do with config files and it is unix specific. I understand your use-case, but I'm not going to add a feature for this into Config::General. But you can implement this yourself, refer to the "PARSER PLUGINS" section. > > > best, > Tom
Subject: Re: [rt.cpan.org #118840] bash/shell expansion/interpolation support
Date: Sat, 19 Nov 2016 00:40:49 +0300
To: bug-Config-General [...] rt.cpan.org
From: Alexey Melezhik <melezhik [...] gmail.com>
Sorry, but I am still not sure if you understand me clearly . You told: Show quoted text
> please read the documentation on the -InterPolateEnv flag. It imports environment variables into the scope of your config file - so, exactly what you want to do.
Ok. I have an environment var $USER: vagrant@Debian-jessie-amd64-netboot:~/my/outthentic$ echo $USER vagrant But get this when try to use it inside my config: vagrant@Debian-jessie-amd64-netboot:~/my/outthentic$ cat /tmp/config.conf user $USER vagrant@Debian-jessie-amd64-netboot:~/my/outthentic$ perl -MConfig::General -e 'Config::General->new( -InterPolateVars => 1 , -ConfigFile => "/tmp/config.conf" )->getall' Use of uninitialized variable ($USER) while loading config entry: user = $USER at -e line 1. 2016-11-19 0:32 GMT+03:00 Alexey Melezhik via RT <bug-Config-General@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=118840 > > > Thanks for explanation, Tom. Now I see. Regards. > > 2016-11-18 23:58 GMT+03:00 T. Linden via RT <bug-Config-General@rt.cpan.org>:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=118840 > >> >> Hi, >> >> please read the documentation on the -InterPolateEnv flag. It imports environment variables into the scope of your config file - so, exactly what you want to do. >> >> However, tilde expansion has nothing to do with config files and it is unix specific. I understand your use-case, but I'm not going to add a feature for this into Config::General. But you can implement this yourself, refer to the "PARSER PLUGINS" section. >> >> >> best, >> Tom
>
Dear Alexey, Show quoted text
> Sorry, but I am still not sure if you understand me clearly.
I see :) But I am sure. Look: Here's what I suggested: Show quoted text
> > please read the documentation on the -InterPolateEnv flag. It imports
Here's what you tried: Show quoted text
> vagrant@Debian-jessie-amd64-netboot:~/my/outthentic$ perl > -MConfig::General -e 'Config::General->new( -InterPolateVars => 1 , > -ConfigFile => "/tmp/config.conf" )->getall'
So, -InterPolateEnv is your friend :) [19.Nov 09:48:34] --- [~] --- tom@niobe: % cat cfg user = $USER [19.Nov 09:48:44] --- [~] --- tom@niobe: % perl -MConfig::General -MData::Dumper \ -e 'print Dumper(Config::General->new(-InterPolateEnv=>1,-ConfigFile=>shift)->getall);' cfg $VAR1 = 'user'; $VAR2 = 'tom'; best regards, Tom
Subject: Re: [rt.cpan.org #118840] bash/shell expansion/interpolation support
Date: Sat, 19 Nov 2016 12:57:14 +0300
To: bug-Config-General [...] rt.cpan.org
From: Alexey Melezhik <melezhik [...] gmail.com>
Ahh, got your point, Tom! It should be InterPolateEnv , but I used InterPolateVars ! :)) You could close this one. Thanks. 2016-11-19 11:50 GMT+03:00 T. Linden via RT <bug-Config-General@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=118840 > > > Dear Alexey, >
>> Sorry, but I am still not sure if you understand me clearly.
> > I see :) But I am sure. Look: > > Here's what I suggested: >
>> > please read the documentation on the -InterPolateEnv flag. It imports
> > Here's what you tried: >
>> vagrant@Debian-jessie-amd64-netboot:~/my/outthentic$ perl >> -MConfig::General -e 'Config::General->new( -InterPolateVars => 1 , >> -ConfigFile => "/tmp/config.conf" )->getall'
> > So, -InterPolateEnv is your friend :) > > [19.Nov 09:48:34] --- [~] --- > tom@niobe: % cat cfg > user = $USER > > [19.Nov 09:48:44] --- [~] --- > tom@niobe: % perl -MConfig::General -MData::Dumper \ > -e 'print Dumper(Config::General->new(-InterPolateEnv=>1,-ConfigFile=>shift)->getall);' cfg > $VAR1 = 'user'; > $VAR2 = 'tom'; > > > > best regards, > Tom