I want to run a command that opens a terminal and sources into it a set of variables.
How can I do this? I'm using xfce4-terminal. It has a command-line arg "--command", to execute commands upon opening the terminal. But that arg doesn't appear to allow execution of the source command.
use terminal's --command flag to open it with sourced environment vars
xfce4-terminal \ --command 'source somefile' \ --hold &
But it just gives an error: failed to execute child process 'source': no such file or directory.
That is what you would try naturally after reading the xfce4-terminal's sparse manpage.
How about specifically invoking bash within the new terminal to source the file?
xfce4-terminal \ --command 'bash -c "source somefile \ --hold &
That executes the source command, but as soon as it is finished the terminal exits.
You might try that after searching the forums and finding it written that one must call bash to run the bash command source. (What is that? Start a terminal with a bash instance to call another bash to run the command)
call bash within bash, within bash, within terminal, to run the command
xfce4-terminal \ --command 'bash -c "source somefile; bash"' \ --hold &
That opens a terminal and keeps it open, but without the sourced environment.
Seems silly, but that's something else you might try after searching the forums.
use bash to call bash with sourced environment
xfce4-terminal \ --command 'bash -c "bash -c \"source somefile; some_command\""' \ --hold &
That sources the new env in a new terminal, but it just closes again as soon as the source cmd has finished executing. (Just some guesswork)
create a script called source_somefile which invokes bash and runs 'source somefile'
xfce4-terminal \ --command 'source_somefile' \ --hold &
No. The terminal closes again as soon as the source cmd has finished executing.
Though you can't be blamed for thinking that would surely work: putting the source cmd in a script and running that using the terminal with the --command flag, so that the --hold flag might also be used to stop the terminal exiting when the source command has finished executing?
How about, running the script as: bash -c 'source somefile'?
No: terminal closes again as soon as the source cmd has finished executing.
So how can this be done, short of printing off the xfce4-terminal manpage and ritually burning it over a blood sacrifice under a harvest moon? And then howling... howling...