-
Notifications
You must be signed in to change notification settings - Fork 821
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
Make the exec command default to a login shell #546
Conversation
How does this behave on Windows ? |
This can be easily fixed by running |
You can do this, but when you are using aws-vault exec often (when your session times out) its quite painful. Also, im not sure why you would ever want to exec into a non login shell? So i think makes sense to default to a login shell?
Good catch! I dont know to be honest, i didn't think of that! Is there anyone who can run |
I finally managed to test this with a vagrant box. By default it executes cmd.exe, which does not like |
490664d
to
660c5e3
Compare
Rather than blacklisting windows, could you whitelist shells that accept the |
I didn't test yet, but wouldn't this cause a second execution of the shell profile under the same environment if |
@segevfiner aws-vault by default won't execute inside it's own shell, which it determines by checking if Can you be more specific about a scenario where this might cause issues? |
I'm running inside a login shell or a shell that has inherited the login shell environment as is the norm in any terminal emulator or IDE embedded terminal. I execute This leads to an environment that has run the login shell script twice, leading to unexpected side effects as that script expects to be called once per session (Unlike the shell rc script, e.g. This assumes that I understood what this PR does. I didn't upgrade seeing this in the change log to avoid issues that I won't have time to work to fix ATM, at least before figuring this out here. |
Yes I see what you're saying @segevfiner. Hmmm maybe I'll revert this for now, aim for v6 to work out how to do this better |
Hey @willejs I've just been playing around with this. I don't think a login shell is required. aws-vault already sends through the entire environment of the current shell to the new shell. What will not come across to the new shell are local variables and functions, which may include your PS1 prompt. If that is what you're noticing, there is a simple solution. Define any local variables and functions like the prompt functions and PS1 in the Does that solve your problem? The problem with the login shell is as @segevfiner described - by running the shell profile scripts again (which are often additive) you can put your shell in a weird state. If a login shell really is required, we probably shouldn't send the entire environment through to the new shell |
It is as described by @mtibben. Anything that should run only once should be in one of the profile script The Also note that many many tutorials and instructions get this wrong too. |
@segevfiner You sent me down a rabbit hole and made me learn something new. Thanks 👍. Based on my new learning I started using |
Currently when you run
aws-vault exec <profile>
it runs $SHELL and puts you into a non login shell. This does not execute your shells login profile so you end up losing anything nice you have in your login profile.Instead I think exec should default to executing a login shell. As far as I am aware all shells support
-l
, so this should be backwards compatible, and i don't envision any issues. This attempts to close out issue #406 too.