Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible somehow to import all environment variables which are exported by a subprocess started by Fish?

E.g. from my Fish session, I start bash ~/.profile, which exports some variables and I want to import those in the Fish session.

(This would also be one solution to my other question; however, this would be much more general. E.g. this would also be a solution to this question.)

share|improve this question

2 Answers 2

Linux has the /proc/<pid>/environ file which contains null-separated environment variables which you could read and import into your fish session.

share|improve this answer

There's no built-in Unix-standard way for a child process to modify the parent process's environment variables, but you could script it up yourself. You could have the child process dump its environment (which is really just a bunch of strings in the format "name=value"), and send it one way or another to the parent, and have the parent walk through the list and export for itself any variables that are new or different (with exceptions for things like $SHELL and $PPID of course).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.