Intel's OneAPI distribution (which includes many components such as ICC) has a script named setvars.sh, which checks for the presence of various stuff, then runs components' individual scripts for setting environment variables. It takes over a second to run and prints some stuff to the terminal.
Now, I'm willing to run it once, but I certainly don't want to run it whenever I start a shell. How can I "cache" its results, in the form of the delta it adds (or removes?) from my environment before its invocation? So that I could just source a script with:
export PATH="whatever:$PATH" export TBBROOT="whatever" # etc. etc.
Naturally, I would need to re-run setvars.sh if my system configuration changed in any way, but I'm ok with that.