How to export dot separated environment variables

前端 未结 4 2099
粉色の甜心
粉色の甜心 2021-02-14 17:56

Execution of

user@EWD-MacBook-Pro:~$ export property.name=property.value

Gives me

-bash: export: `property.name=property.value\         


        
4条回答
  •  野性不改
    2021-02-14 18:43

    I spent better part of this afternoon trying to figure out how to access some property set by Jenkins (to pass a job parameters jenkins uses property format with a dot) - this was a good hint from Adrian and yes it works for reading properties in the script too. I was at a loss as to what to do but then I tried:

    var=`perl -e 'print $ENV{"property.name"};print "\n";'`
    

    This worked quite well actually. But of course that works in a shell that was started with the property set in the environment already i.e. in Adrian's example this could work in a script started from bash instance invoked in perl example he provided. It would not if this perl sniplet was put in the same shell only directly after his perl example.

    At least I learnt something this afternoon so not all this time is a waste.

提交回复
热议问题