-
Notifications
You must be signed in to change notification settings - Fork 226
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
faf922302 breaks everything #371
Comments
cc @bobthecow |
this is interesting... I see you had a check (
Yeah, I think this is what going on, fish for some reason parses and checks
this ^^^^^^ results in the error. |
As a temporary workaround:
|
Sorry, and thanks for looking into this! That's weird. I have no idea why the builtin check isn't gating that line properly. I'm unfortunately unable to dig into this for a couple of weeks. If you can come up with a workaround I'd appreciate a PR. Otherwise your best bet might be checking out the revision just before that change until I can get a chance to work on it. |
@bobthecow @juleek Putting $ in front of path.
However, I dont't use linux much and my environment is virtual. The environment is as follower
|
This is working for you because it's checking whether there's a builtin with the value of your system $path variable, which will almost certainly be false for everyone all the time. You could also prevent the issue by just deleting the check entirely and returning the "else" branch of the if statement. That wouldn't help people who do have a working path builtin though :) |
Just a wild guess based on observation. I put an
Yet my poor-mans-debugger was nowhere to be seen. My guess is that function __bobthefish_closest_parent -S
if builtin -q path
set -l pathCmd "builtin path"
echo ($pathCmd sort -r $argv)[1]
else
string join \n $argv | awk '{ print length, $0 }' | sort -nsr | head -1 | cut -d" " -f2-
end
end After diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index e1df158..f53fd8b 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -1258,7 +1258,8 @@ end
# Polyfill for fish < 3.5.0
function __bobthefish_closest_parent -S
if builtin -q path
- echo (builtin path sort -r $argv)[1]
+ set -l pathCmd "builtin path"
+ echo ($pathCmd sort -r $argv)[1]
else
string join \n $argv | awk '{ print length, $0 }' | sort -nsr | head -1 | cut -d" " -f2-
end |
If you extract the builtin path line into its own function (which is only called in the conditional branch) does it explode? (If so) what if you move that function into its own file under the functions dir? |
@bobthecow i just added the following function: function __builtInPath -S
echo (builtin path sort -r $argv)[1]
end The function is not called anywhere, it's mere presence is enough to produce the error. |
I suspected as much. What if you move it into its own file (with the name of the function) under the functions directory, but never call it or source the file? |
If I understand it correctly, fish-shell/fish-shell@0325c1b added parse-time errors for builtins (11 years ago!). I’m not sure if there is a way to do conditional builtin calls or not, other than by something equivalent to “eval” as you mentioned. but, there’s a chance we can avoid parsing it entirely, by moving the offending call into a file with its own function. fish function autoloading probably is runtime, not parse time, so my guess is that it’ll work. |
Since there’s no way for the existing thing to safely work, i’ve reverted the change in HEAD. Let’s keep this issue open for a bit and see if we can come up with a way to make it work. |
Here's what I tried and what the outcome was:
Here's the function: function __bobthefish_get_path_by_builtin -S
echo (builtin path sort -r $argv)[1]
end HTH |
yeah, after checking the error implementation, just the gated bit would have to be in an autoloaded file, because we have to prevent that file from ever being parsed. thanks for looking into it. i'll take a shot at getting an improved implementation out in a couple of weeks, but in the meantime you can update to the latest theme version and pick up the revert. |
After this commit: faf9223, I started getting:
Using this version because this is the default in 22.04
The text was updated successfully, but these errors were encountered: