From e6ccf9e3f37cc1a4727976ca8b3eb12330d33216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20=C3=96hman?= Date: Thu, 11 Apr 2024 18:07:55 +0000 Subject: [PATCH] Move PS1 and history to env file (simplifies and fixes escaping) --- easybuild/tools/run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easybuild/tools/run.py b/easybuild/tools/run.py index 60d1d789be..d0549a5c6b 100644 --- a/easybuild/tools/run.py +++ b/easybuild/tools/run.py @@ -214,6 +214,8 @@ def save_cmd(cmd_str, work_dir, env, tmpdir): # excludes bash functions (environment variables ending with %) fid.write('\n'.join(f'export {key}={shlex.quote(value)}' for key, value in full_env.items() if not key.endswith('%'))) + fid.write('\n\nPS1="eb-shell> "') + fid.write(f'\nhistory -s {shlex.quote(cmd_str)}') # Make script that sets up bash shell with given environments set. cmd_fp = os.path.join(tmpdir, 'cmd.sh') @@ -225,9 +227,7 @@ def save_cmd(cmd_str, work_dir, env, tmpdir): 'EB_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )', f'echo Shell for the command: {shlex.quote(cmd_str)}', 'echo Use command history, exit to stop', - 'bash --rcfile <(cat $EB_SCRIPT_DIR/env.sh; ' - 'echo \'PS1="eb-shell> "\'; ' - f'echo history -s {shlex.quote(cmd_str)})', + 'bash --rcfile $EB_SCRIPT_DIR/env.sh', ])) os.chmod(cmd_fp, 0o775)