forked from qt-creator/qt-creator
macOS: Fix opening and running in terminal with zsh
We need to read different startup files for zsh. Task-number: QTCREATORBUG-21712 Change-Id: Id10b185e3957b44423e847114adc1b3085a8089d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -54,10 +54,10 @@ while read -r line; do
|
||||
done < <(env)
|
||||
'''
|
||||
|
||||
def system_login_script():
|
||||
def system_login_script_bash():
|
||||
return 'if [ -f /etc/profile ]; then source /etc/profile; fi\n'
|
||||
|
||||
def login_script():
|
||||
def login_script_bash():
|
||||
return '''
|
||||
if [ -f $HOME/.bash_profile ]; then
|
||||
source $HOME/.bash_profile
|
||||
@@ -68,6 +68,16 @@ elif [ -f $HOME/.profile ]; then
|
||||
fi
|
||||
'''
|
||||
|
||||
def system_login_script_zsh():
|
||||
return '[ -r /etc/profile ] && source /etc/profile\n'
|
||||
|
||||
def login_script_zsh():
|
||||
return '''
|
||||
[ -r $HOME/.zprofile ] && source $HOME/.zprofile
|
||||
[ -r $HOME/.zshrc ] && source $HOME/.zshrc
|
||||
[ -r $HOME/.zlogin ] && source $HOME/.zlogin
|
||||
'''
|
||||
|
||||
def environment_script():
|
||||
return ''.join(['export ' + quote_shell(key + '=' + os.environ[key]) + '\n'
|
||||
for key in os.environ])
|
||||
@@ -98,6 +108,10 @@ end tell
|
||||
def main():
|
||||
# create temporary file to be sourced into bash that deletes itself
|
||||
with NamedTemporaryFile(delete=False) as shell_script:
|
||||
shell = os.environ.get('SHELL')
|
||||
shell_is_zsh = shell is not None and shell.endswith('/zsh')
|
||||
system_login_script = system_login_script_zsh if shell_is_zsh else system_login_script_bash
|
||||
login_script = login_script_zsh if shell_is_zsh else login_script_bash
|
||||
quoted_shell_script = quote_shell(shell_script.name)
|
||||
commands = (clean_environment_script() +
|
||||
system_login_script() + # /etc/profile by default resets the path, so do first
|
||||
|
Reference in New Issue
Block a user