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
Log shell cmds to temp file which allow users to revisit them #4486
base: 5.0.x
Are you sure you want to change the base?
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. |
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.