Skip to content

Commit b152dd3

Browse files
authored
Nested shells should not be login (#5247) (#5565)
1 parent 94af525 commit b152dd3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

notebook/terminal/__init__.py

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

0 commit comments

Comments
 (0)