Bash should be run as a login shell
See original GitHub issueIt looks like bash understands $SHELL
but this shell is not a login shell which means people who have customized their $PROMPT_COMMAND
in their Dotfiles end up with weird errors.
A couple of solutions I can think of.
- Run bash with
--login --interactive
- Rather than just running
$SHELL
, you can runexec
and source the virtualenv.- This has the added bonus of having the same virtualenv flow and running `deactivate.
- Running Ctrl-D is error prone, I quit the shell thinking I’m inside
pipenv shell
many many times.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Difference between Login Shell and Non-Login Shell?
From bash manual, A login shell is one whose first character of argument zero is '-', or one invoked with the --login option....
Read more >What does "Run command as a login shell" do? - Ask Ubuntu
When running as a login shell, Bash will read ~/.bash_profile (or, if that doesn't exist, ~/.profile ) on startup. In some cases, this...
Read more >What is Login Shell in Linux?
The login shell is the first process that is executed with your user ID when you log into an interactive session.
Read more >Login shells
A login shell is a shell given to a user upon login into their user account. This is initiated by using the -l...
Read more >Invoking Bash (Bash Reference Manual) - GNU.org
When the shell is interactive, this is equivalent to starting a login shell with ' exec -l bash '. When the shell is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just read through some of the pew docs (that was helpful), so I’m looking right here in the troubleshoot section.
They recommend that you move your
PATH
declarations into~/.profile
and execute as a login shell.Also, this table was really helpful me figure out why
~/.profile
was not getting sourced/etc/profile
~/.bash_profile
~/.bash_<span class="search_hit mark">login</span>
~/.profile
~/.bashrc
${ENV}
After reading the pew docs and combing deep caverns of shell scripting lore I discovered that functions can be exported (who knew that was a thing!).
function export example
So let’s say I have function that fork bombs your shell and I want to hot potato it into a child shell processes.
Keep forking to a minimum
Bash prevents child processes from cases of unprotected forking somtimes…. You need to explicitly flag functions using
export -f foobar
ordeclare -fx foobar
.Environment is copy by value
Even if the functions are bound to environment variables that are themselves exported, the new sub shell is passed a new copy of the functions and not a reference.
A good example is
${PROMPT_COMMAND}
which is usually bound to a function that populates the variable. That function will get called every time$PS1
is displayed so make sure to export it.