Search - User list
Full Version: Importing `houdini.env` into the shell
Root » Technical Discussion » Importing `houdini.env` into the shell
gadfly16
Hi,

is there a tool, that parses and exports the variables defined in the `houdini.env` file into a shell? (To bash in my case.)

Thanks,
Mate
jsmack
cat houdini.env
gadfly16
Thanks for the insightful answer!

Unfortunately by “export” I mean exporting not printing: Exporting Variables [bash.cyberciti.biz] .

To be more exact I would like to have a bash shell where the environment variables defined in `houdini.env` are set. In my understanding this is only achievable by setting these variables and start a sub-shell, since a sub-process can not export to its parent. But those who know the answer will aware of this detail..

I hope this further clarifies my question.

Thanks again,
Mate
KaiStavginski
You can set variables from a bash script if you just source it. But the houdini.env file doesn't exactly contain shell commands.

In bash you could do something like this:

$(cat houdini.env | grep -v "#" | grep "=" | xargs -L1 echo export)

grep -v “#” just filters out comment lines
grep “=” filters for lines actually containing an assigment

xargs -L1 echo export just prints each line with “export” prepended.

So you get output like

export HOUDINI_NO_SPLASH=1

Wrapping the whole command in $() will execute the whole thing as a shell command.

Bash also requires that there's no space around the =. Just make sure of that in your file, I didn't take care of that in the one-liner.
gadfly16
Thanks a lot!

That's super useful for my case.

Best regards,
Mate
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB