Skip to content

Commit

Permalink
Move PS1 and history to env file (simplifies and fixes escaping)
Browse files Browse the repository at this point in the history
  • Loading branch information
Micket committed Apr 14, 2024
1 parent 3c20328 commit e6ccf9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions easybuild/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)

Expand Down

0 comments on commit e6ccf9e

Please sign in to comment.