complete.cpp does not parse PATH directories with parenthesis correctly. #952
Comments
|
Yes, I can reproduce this: mkdir ~/\(blah\)
set -gx PATH ~/\(blah\)
ln -s /bin/tar ~/\(blah\)/somenewcommand
somenew<tab>
in command substitution
called on standard input,
somenew |
X86. Great. Thanks for helping me finding the issue. I think the |
|
After some experimentation, I found out it also applies to CDPATH expansion (when using |
|
The issue here is in It's surely wrong to do these expansions in the components of $PATH. It's somewhat less wrong to do them in the expansions of commands, i.e. if I do this: What should it expand to? Should it turn into 'python' or 'pyt?on' or nothing at all? |
|
The current behavior is sort of silly. When executing a command containing a wildcard, it calls expand_one. So if the wildcard has a single match, that is executed; if there are multiple matches, it prints the misleading "Illegal command name" error. |
|
I feel a little better about fish after comparing it to other shells. zsh, bash, and tcsh all expand the wildcard |
|
Perhaps that should replace "a command-line shell for the 90s" as our tagline. |
|
I just installed fish from the cygwin repositories and I see this as well. |
|
@HakanSiktas: Strange, I assumed I "fixed" very specific case of But well, the issue not fixed, I just applied a quick hack in order to make this build feel less buggy. Of course it still needs fixing, and it would be nice to get it fixed in the next release. It's actually surprisingly important on one specific platform called Windows, where one of directories is called "Program Files (x86)". I think it could be considered unimportant bug, but I think that Windows makes it more important than it seems initially. EDIT: Now that I look into it, the patch wasn't applied. Oops. Well, you may want to put this to ~/.config/fish/config.fish. This is temponary workaround, at least until the issue will be fixed. function x86
echo '(x86)'
end
function X86
echo '(X86)'
end |
|
Hah, that's brilliant! |
|
When do you plan to release a patch ? This makes using fish under Cygwin very annoying (which is a shame as fish does seem to be a killer shell :) ) |
|
This is currently slated for the next release, but there's not an ETA yet. |
|
After installing fish on msys2, I'm getting this bug. It seems we still haven't quite fixed it... Hoping this bumps it higher up because I really rely on msys2/cygwin for work, and fish makes it so much more comfortable. |
|
Also seeing this. |
|
Is this an issue in complete.cpp or actually in the completion scripts, especially "cd"s (hint: #2289)? I've just tried mkdir "Program Files (x86)"
cd Prog<TAB>(with that PR applied) and it worked. |
|
Yay! |
|
This still isn't fixed: mkdir -p ~/\(blah\)
ln -s /bin/tar ~/\(blah\)/somenewcommand
set -gx PATH ~/\(blah\) $PATHThen type |
|
the specific instance of |
|
If no one else is working on fixing this I'll take a stab at it. |
|
That would be great, Kurtis. Much appreciated! |
|
There are concerns (many thanks to Josh for raising them) that this can be used to cause privilege escalation or arbitrary code execution for other users. Since the I thought about trying to add a symlink to a bracket-containing directory to the path, but the symlink is not derefenced so that can't be used. |
|
In other words, although I think a definitive fix would be great, I don't think this needs to block 2.3.0. |
|
Thanks zanchey. I'll also look to see how feasible a fix is. |
Or convince someone to do basically anything. |
Prior to this fix, when completing a command that doesn't have a /, we would prepend each component of PATH and then expand the whole thing. So any special characters in the PATH would be interpreted when performing tab completion. With this fix, we pull the PATH resolution out of complete.cpp and migrate it to expand.cpp. This unifies nicely with the CDPATH resolution already in that file. This requires introducing a new expand flag EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD (which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to resolve paths against PATH instead of the working directory. Fixes #952
Prior to this fix, when completing a command that doesn't have a /, we would prepend each component of PATH and then expand the whole thing. So any special characters in the PATH would be interpreted when performing tab completion. With this fix, we pull the PATH resolution out of complete.cpp and migrate it to expand.cpp. This unifies nicely with the CDPATH resolution already in that file. This requires introducing a new expand flag EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD (which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to resolve paths against PATH instead of the working directory. Fixes #952
|
I have a fix for this in #2912. It's nice because it unifies completions for commands (which need to respect PATH) with those for cd (which respect CDPATH). @krader1961 (or anyone) do you want to review? |
Prior to this fix, when completing a command that doesn't have a /, we would prepend each component of PATH and then expand the whole thing. So any special characters in the PATH would be interpreted when performing tab completion. With this fix, we pull the PATH resolution out of complete.cpp and migrate it to expand.cpp. This unifies nicely with the CDPATH resolution already in that file. This requires introducing a new expand flag EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD (which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to resolve paths against PATH instead of the working directory. Fixes #952
Prior to this fix, when completing a command that doesn't have a /, we would prepend each component of PATH and then expand the whole thing. So any special characters in the PATH would be interpreted when performing tab completion. With this fix, we pull the PATH resolution out of complete.cpp and migrate it to expand.cpp. This unifies nicely with the CDPATH resolution already in that file. This requires introducing a new expand flag EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD (which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to resolve paths against PATH instead of the working directory. Fixes #952
|
The change proposed by @ridiculousfish fixes the core issue. But, FWIW, other problems remain. For example, my |
|
@krader1961 that problem is due to |
|
@krader1961: Should be fixed in d7c690b.
Do we already have a C++ completion for enterable directories that takes into account $CDPATH? |
|
Yes - the logic is there to service the autosuggestion. |
When I reviewed the fix for #952 I noted that "../" wasn't handled but in my haste to merge it forgot to augment the pull-request.
|
FWIW, @faho's change fixed the |
I am having this problem in Windows, but I have a feeling it will happen in other OS as well.
When I try to autocomplete any command, I get the following message 11 times:
This corresponds to the number of directory that includes "Program Files (x86)" in PATH.
I have no trouble running binaries in these directories. For example, firefox is correctly identified as a binary and I can execute it, even though it is in '/cygdrive/c/Program Files (x86)/Mozilla Firefox/firefox.exe'.
The text was updated successfully, but these errors were encountered: