There is a script “X”, which depending on input will export some environment variables.
To run “X” within another script “Y”, I do the following:
echo "some input" > temp_file
source X < temp_file
Is there a alternative way to do this, without using temporary files?
As I understand in case of pipes a sub-process is created, and by running the following line
echo "some input" | source X
the environment variables can’t be set or modified within a current script.
Use process substitution:
It basically allows you to redirect the input/output of a process to another process as if it were a file.