From d07273042544d16ebbac8e228f78f36466993525 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:14:34 -0700 Subject: [PATCH] Use osascript in order not to pollute shell history on macOS --- spyder/plugins/updatemanager/widgets/update.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index 77725ff9475..54015106d0a 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -436,14 +436,15 @@ def start_install(self): if os.name == 'nt': cmd = ['start', '"Update Spyder"'] + sub_cmd elif sys.platform == 'darwin': - # Terminal cannot accept a command with arguments therefore - # create a temporary script - tmpscript = osp.join(get_temp_dir(), 'tmp_install.sh') - with open(tmpscript, 'w') as f: - f.write(' '.join(sub_cmd)) - os.chmod(tmpscript, 0o711) # set executable permissions - - cmd = ['open', '-b', 'com.apple.terminal', tmpscript] + # Terminal cannot accept a command with arguments. Creating a + # wrapper script pollutes the shell history. Best option is to + # use osascript + sub_cmd_str = ' '.join(sub_cmd) + cmd = [ + "osascript", "-e", + ("""'tell application "Terminal" to do script""" + f""" "set +o history; {sub_cmd_str}; exit;"'"""), + ] else: programs = [ {'cmd': 'gnome-terminal', 'exe-opt': '--window --'},