New submission from Siming Yuan <simin...@gmail.com>:
Using os.execl you can open a new bash shell (eg, using python to process some env before opening a new shell. $ echo $SHLVL 1 $ ~/.pyenv/versions/3.6.4/bin/python3 Python 3.6.4 (default, Feb 5 2018, 16:53:35) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.execl('/bin/bash', '') $ echo $SHLVL 2 Doing the above works with just /bin/bash no arguments. (notice SHLVL incrementing) But providing your own custom --init-file or --rcfile, doesn't. eg - /bin/bashrc --rcfile <path to a venv activate file> $ echo $SHLVL 1 $ ~/.pyenv/versions/3.6.4/bin/python3 Python 3.6.4 (default, Feb 5 2018, 16:53:35) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.execl('/bin/bash', '--rcfile','/users/me/venv/bin/activate') $ echo $SHLVL 1 this can be replicated in Python 3.5 to 3.7 can be worked-around if using a wrapper.sh file with: #! /bin/bash exec /bin/bash --rcfile /users/me/venv/bin/activate and running this file in os.execl() instead. ---------- messages: 343654 nosy: siming85 priority: normal severity: normal status: open title: os.execl opening a new bash shell doesn't work if initfile/rcfile provided versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37066> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com