-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
bash_it.sh: Require interactive shell #1533
bash_it.sh: Require interactive shell #1533
Conversation
Previously, a fix was added for bad behavior when `bash-it` printed text to the console in conjunction with protocols like `SCP`, as commit 83c44fa "template/profile: Require interactive shell". It did work for those users who replace their original `~/.bash_profile` file with the one provided by `bash-it`, but not for those who merely append a `bash-it` call to their existing `~/.bash_profile` file. Fix the behavior for the latter case, too.
Apparently, tests are run in non-interactive mode, so they will need to be adapted or the business logic for interactive mode moved to a separate script so it can be tested. |
Thanks for providing this fix - can you please take a look at the broken test cases? |
Greetings All, Question: Is it possible that, even in non-interactive mode, the user may be trying to do something that requires (at least parts of) bash-it to initialize? I'm thinking something along the lines of expecting an alias or plugin to be configured? say, pyenv or somesuch? Just wondering if this is something to be concerned about what with the user delegating so much of their startup routine to bash-it (per design). NOTE: This PR seems to keep par with the current pattern introduced Here, but with the user no-longer having direct control over it, I thought it might be worth discussing. Wondering if we might find something like this useful: ~/.bash_profile
I tested this locally with a few shell scripts and it worked as expected. Thoughts? -DF |
IMHO, that's something people shouldn't do.
I found that SCP transfers were slow to start in such a setting because of all the time it takes to run I lean towards a different approach where there is an external The matters seem a bit more complex than initially thought, we'll probably need additional automated tests for a swift discussion. Next time, I will look into testing with |
Thanks for discussing this - the SCP use case is pretty important, true. We should make sure that whatever we does not result in longer init times when doing things like SSH, SCP, etc. I'm not sure I understand the external/internal approach - can you please provide some more details on that, @rico-chet? |
With the current PR, we have the issues that:
The approach is to have:
Then, when printing is added to Alternatively, we could add an environment variable, e.g. |
I would lean toward keeping one access point for users, ie. I think there's value in supporting a concept of
or
The 2nd option offers more flexibility, but the 1st option most-likely matches real-world usage. Themes and Completions seem to clearly fit into the "Interactive-Only Components" category. Plugins and Aliases may be a bit more nuanced. These components could potentially tag themselves (using meta-data) as interactive or non by default. I think the user should have the ability to override the default on a per-component basis. Maybe something like
This could give the user the ability to orchestrate both their interactive and non-interactive sessions. The user could get creative in their bash_profile and add ssh_detection code and then control exactly which components should be initiated for ssh/scp sessions. NOTE: Components are still expected to be enabled via Additionally, I think my idea of routing all output to -DF |
I really like this idea of plugins having the option of being always on vs interactive only. However, I kinda see this PR as a bug fix, since it sounds like this hasn't been thought out previously. I know I've had to wrap my bash-it includes with this clause and has annoyed other people I've gotten to adopt bash-it. In that vein, I think it'd be great if this PR could be merged (once travis is happy) and further discussion moved to an issue maybe? I hope I don't come off like a jerk, I'm just trying to keep things moving :-) |
@rico-chet ping |
To make Travis happy, we would need to figure out how to run the tests in CI pretending the shell is interactive, because otherwise they just fail. Shouldn't be hard but might have side effects. A new test would be handy which proves that SCP scenarios work fine. I made some progress running SSH server in a docker container but failed to get the test red. And the question of how we deal with existing expectations isn't really solved. Due to lack of knowledge of bash-it internals I cannot come up with a simple solution yet. |
For now, I found that it's complicated on the A quick attempt to make existing tests green wasn't successful, so it will take a while for me to get it done, if at all. If anybody's interested to pick it up, feel free to do so. Since personally, I'm not affected by the issue and am spending my spare time on other activities recently, it's not going to be done soon otherwise. |
I'm in the same boat. If I find spare time or need a break from work, I might copy your work to a branch and see what I can pull off. Edit: thanks for all the hard work and for taking the time to follow up! |
If I may add my $0.02, I think that Bash It isn't the right place for deciding if it should load itself whether interactive or not. This feels like something that should be handled in |
Previously, a fix was added for bad behavior when
bash-it
printed textto the console in conjunction with protocols like
SCP
, as commit83c44fa "template/profile: Require interactive shell".
It did work for those users who replace their original
~/.bash_profile
file with the one provided by
bash-it
, but not for those who merelyappend a
bash-it
call to their existing~/.bash_profile
file.Fix the behavior for the latter case, too.
This serves as a preparation for #1501