Skip to content

Commit 9e18c8e

Browse files
dlukeskevin-bates
authored andcommitted
Nested shells should not be login (#5247) (#5565)
1 parent e3de58b commit 9e18c8e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

jupyter_server/terminal/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ def initialize(webapp, root_dir, connection_url, settings):
2222
shell = settings.get('shell_command',
2323
[os.environ.get('SHELL') or default_shell]
2424
)
25-
# Enable login mode - to automatically source the /etc/profile script
26-
if os.name != 'nt':
25+
# Enable login mode - to automatically source the /etc/profile
26+
# script, but only for non-nested shells; for nested shells, it's
27+
# superfluous and may even be harmful (e.g. on macOS, where login
28+
# shells invoke /usr/libexec/path_helper to add entries from
29+
# /etc/paths{,.d} to the PATH, reordering it in the process and
30+
# potentially overriding virtualenvs and other PATH modifications)
31+
if os.name != 'nt' and int(os.environ.get("SHLVL", 0)) < 1:
2732
shell.append('-l')
2833
terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(
2934
shell_command=shell,

0 commit comments

Comments
 (0)