-
Notifications
You must be signed in to change notification settings - Fork 178
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
Intermediate source <(mcfly init *sh)
during initialisation. Fixes #254, #219, #239
#255
Intermediate source <(mcfly init *sh)
during initialisation. Fixes #254, #219, #239
#255
Conversation
This resolves the init scripts having too much power in users' config. For example a `return 0` in mcfly's init returned from the user's _whole_ .zshrc script. Thus failing to run any further commands such as: `bindkey '^R' mcfly-history-widget` But more importantly failing to run the rest of .zshrc. Should also resolve cantino#219 and cantino#239
Thanks @tombh! Merged. Are you able to check if this has fixed the bug for you? |
Actually, I'm getting panics when I run
This is launching bash from zsh, my default shell. |
I'm primarily a zsh user too, so I may have overlooked something for bash. I just assumed they were similar enough that the both needed the same solution. But I might be wrong. Anyway, I went as far as testing like this from with a bash shell: [tombh@tombox mcfly]$ source <(cargo run -- init bash --print_full_init)
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/mcfly init bash --print_full_init`
[tombh@tombox mcfly]$ And |
I built and installed it locally: |
I just repeated that exactly, and can't reproduce the bug. Can you paste the contents of your |
That's very odd. I tried adding a newline to your outputs too. Are you on a Mac? Maybe related to this? nix-community/nix-index#69
Backing up a second, what was the reasoning around not just changing the init scripts to be wrapped in a conditional if `if ! [[ "$__MCFLY_LOADED" == "loaded" ]]; then`?
|
I'm on Arch (by the way haha). What are the newlines for? To replicate the difference between
That's certainly one approach. But the advantage of using process substitution, namely |
Oh, are you on Mac? Because there is indeed some issues mentioned with this kind of init in the Starship code, have a look: https://github.com/starship/starship/blob/17453929091b1d9463f33e0b291436c9213c54d2/src/init/mod.rs#L104 |
Oh interesting, that’s probably it. I guess we should just do the conditional around the scripts? Seems easiest.
|
If Starship can do it, so can we! Look, this is what they use for lower Bash versions: Does it help you? Are you Mac? |
I am on a Mac, yes. No, that isn't working for me. Running I'm leaning toward just conditionalizing the scripts for now. |
There's an interesting comment at the top of that Starship file: /*
We use a two-phase init here: the first phase gives a simple command to the
shell. This command evaluates a more complicated script using `source` and
process substitution.
Directly using `eval` on a shell script causes it to be evaluated in
a single line, which sucks because things like comments will comment out the
rest of the script, and you have to spam semicolons everywhere. By using
source and process substitutions, we make it possible to comment and debug
the init scripts.
In the future, this may be changed to just directly evaluating the initscript
using whatever mechanism is available in the host shell--this two-phase solution
has been developed as a compatibility measure with `eval $(starship init X)`
*/ So wrapping the init scripts in a big conditional won't solve the bigger issue. Directly I think we're close. Starship is Rust, and they've already successfully solved all these pieces. We've found the cause of your bug, and so just need to get over that final hurdle. If you don't have time to figure it out, then I think the better compromise is to only fallback for Bash <v4.1 users, something like this: local major="${{BASH_VERSINFO[0]}}"
local minor="${{BASH_VERSINFO[1]}}"
if ((major > 4)) || {{ ((major == 4)) && ((minor >= 1)); }}; then
source <(mcfly init bash --print_full_init)
else
mcfly init bash --print_full_init
fi |
Starship's |
I think you misunderstood my advice in that previous comment. The Also, I didn't realise that Rust is escaping brackets with another bracket |
Oh, because this PR is closed the commit isn't automatically showing up. It's here: tombh@54984f8 I'll have to make another PR for it, if you want it. |
Right, but the |
Oh I made a typo, it should be |
If you want to remake the PR with the correct code, I'm happy to give it another try locally. |
As requested in #254.
I don't know anything about Fish, but I assume this issue didn't affect it?