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.)


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


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).

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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