-
Notifications
You must be signed in to change notification settings - Fork 218
create env.sh and cmd.sh helper scripts in run_shell_cmd
#4486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5c65182 to
50b98c5
Compare
|
I think this is good. I haven't actually tested using it yet (need to set up EB5 testing environment) |
|
I had to make some adjustments due to how exported variables, history and rcfiles work with bash. But it was all for the better. Now it generates a big env.sh file with the entire environment (exported) export CC=gcc
export CXX=g++
export LMOD_CMD=/usr/share/lmod/lmod/libexec/lmod
...and a cmd.sh file that sources this environment into an interactive shell + change directory + helpful text + command history + custom prompt #!/usr/bin/env bash
cd "/dev/shm/Bison/3.8.2/system-system/bison-3.8.2"
EB_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo Shell for the command: './configure --prefix=/apps/Test2/software/Bison/3.8.2 --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu'
echo Use command history, exit to stop
bash --rcfile <(cat $EB_SCRIPT_DIR/env.sh; echo 'PS1="eb-shell> "'; echo history -s './configure --prefix=/apps/Test2/software/Bison/3.8.2 --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu')I've actually tested so that it works and i already love it |
|
All that remains here is how to display the existence of these additional files to the user. Currently, one would see: and I could add more lines like or we could consider just pointing to the directory: |
|
I moved my PS1 and history to the cmd.env file instead, allowing it to be used as an rcfile directly. This simplifies the code but more importantly also avoid trouble with echo removing quotes around strings, so, this is now robust against quotes and spaces in the cmdstr. |
env.sh and cmd.sh helper scripts in run_shell_cmd
boegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…l_cmd + enhance test to verify they're working as intended
minor tweaks to dumping of `env.sh` + `run.sh` helper scripts in `run_shell_cmd` + enhance test to verify they're working as intended
… add test for env option in run_shell_cmd
boegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix handling of specified command environment in `create_cmd_scripts` + add test for env option in `run_shell_cmd`
boegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some ideas to improve this further, but those can be implemented in a follow-up PR
fixes #970
As discussed, I think this would be a greatly useful feature for anyone struggling to
Rather than directly dropping users into the shell when things fail, just writing these temp files allow some advantages, primarily:
Maybe we want to be able to limit when we generate this? Maybe, we do run a lot of shell cmds so i guess many of these are not worth ever really revisiting.
This is completely untested yet, just my somewhat formed ideas.