Differences between revisions 17 and 19 (spanning 2 versions)
Revision 17 as of 2016-08-28 03:07:19
Size: 979
Editor: ormaaj
Comment: on second thought, /dev/fd
Revision 19 as of 2016-08-31 00:04:54
Size: 1047
Editor: ormaaj
Comment: Eh? /dev/fd was not a Linux invention and is widely available. Procsub's _only_ advantage is the fifo fallback (and only 3 shells support it). Also IMO it's better to pass a seekable file.
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
}}}

Or:

{{{
bash --rcfile <(printf %s 'my; commands; here')

I want to launch an interactive shell that has special aliases and functions, not the ones in the user's ~/.bashrc.

Just specify a different start-up file:

bash --rcfile /my/custom/bashrc

Or:

bash --rcfile <(printf %s 'my; commands; here')

Or:

 ~ $ bash --rcfile /dev/fd/3 -i 3<<<'cowsay moo'
 _____
< moo >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
+bash-4.3$ exit
exit

Variant question: I have a script that sets up an environment, and I want to give the user control at the end of it.

Put exec bash at the end of it to launch an interactive shell. This shell will inherit the environment (which does not include aliases, but that's OK, because aliases suck). Of course, you must also make sure that your script runs in a terminal -- otherwise, you must create one, for example, by using exec xterm -e bash.


CategoryShell

BashFAQ/023 (last edited 2016-08-31 00:32:52 by ormaaj)