Remix.run Logo
ffsm8 3 days ago

Mmh, that's kinda... Exactly what `source` is.

It's just rarely used beyond dotfiles because... Well.. it inherits all variables etc

https://docs.vultr.com/how-to-use-the-source-command-in-bash

If you want to make the transition explicit at the end of the script, you can do what the sister comment did, essentially

"source <(bash the-script|grep -Pom "xx inherited variables\n(.*?)\n yy inherited variables")"

donatj 3 days ago | parent [-]

Not at all. The source command is basically just an include, executing shell commands in the current scope.

I'm talking about inheriting the environmental state of any subprocess. You can't source a binary.

ffsm8 3 days ago | parent [-]

Can you tell me an example where this has a difference in behaviour?

Basically somewhere that source would not behave as you wanted?

I'm also uncertain what you mean wrt a binary. A binary will only have the environment variables available to the shell it's executed in - or do you mean that you'd also want it to inherit variables the binary itself might read from disk via .env files or similar?