Differences between revisions 4 and 16 (spanning 12 versions)
Revision 4 as of 2008-05-15 18:54:08
Size: 678
Editor: GreyCat
Comment: #faq80 -> /080
Revision 16 as of 2016-08-28 02:56:37
Size: 1013
Editor: ormaaj
Comment: moo
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[Anchor(faq23)]]
== I want to launch an interactive shell that has a special set of aliases and functions, not the ones in the user's ~/.bashrc. ==
<<Anchor(faq23)>>
== 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:
Line 8: Line 9:
Or:

{{{
 ~ $ bash --rcfile - <<<'cowsay moo; exec <&2' -i
+bash-4.3$ cowsay moo; exec <&2
 _____
< moo >
 -----
        \ ^__^
         \ (oo)\_______
            (__)\ )\/\
                ||----w |
                || ||
+bash-4.3$ exit
exit
}}}
Line 10: Line 28:
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 [:BashFAQ/080: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}}}. 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 [[BashFAQ/080|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

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 - <<<'cowsay moo; exec <&2' -i
+bash-4.3$ cowsay moo; exec <&2
 _____
< 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)