Importing `houdini.env` into the shell

   2374   4   0
User Avatar
Member
65 posts
Joined: 5月 2009
Offline
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
User Avatar
Member
7740 posts
Joined: 9月 2011
Online
cat houdini.env
User Avatar
Member
65 posts
Joined: 5月 2009
Offline
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
Edited by gadfly16 - 2020年8月12日 03:53:50
User Avatar
スタッフ
637 posts
Joined: 8月 2013
Offline
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.
Kai Stavginski
Senior Technical Director
SideFX
User Avatar
Member
65 posts
Joined: 5月 2009
Offline
Thanks a lot!

That's super useful for my case.

Best regards,
Mate
  • Quick Links