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
Change regex of abbr add to allow non-letters-only abbrs #2996
Conversation
This did work in 2.2, so it is a regression. |
Merged, thanks! Out of curiosity - what abbr did you try to create? |
(cherry picked from commit 1c6f6df)
Also pushed to Integration_2.3.0, since it is a regression. |
@@ -85,7 +85,7 @@ function abbr --description "Manage abbreviations" | |||
set key $kv[1] | |||
set value $kv[2] | |||
# ensure the key contains at least one non-space character | |||
if not string match -qr "\w" -- $key | |||
if not string match -qr "[^\s]" -- $key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't both of these incorrect? Shouldn't the key be a contiguous sequence of non-space characters? This allows "abc def" as a valid abbreviation. But if you actually execute abbr -a "abc def" "wtf"
as soon as you type abc[space]
it expands to def wtf
. It seems to me the correct regex is '^\S+$'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the regex is technically wrong but it doesn't matter because of how $mode_arg
is constructed and the behavior of __fish_abbr_split
. They collude to turn abbr -a "abc def" "wtf"
into the equivalent of abbr -a abc "def wtf"
. Which is truly surprising behavior and clearly not what the user intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, sure, technically you're right. But with this change it's not a regression any more. So it's good to go for 2.3.0.
@faho I tried to make this: function sudobangbang --on-event fish_postexec
abbr !! sudo $argv[1]
end I also added it to the wiki-page for "Bash Style History Substitution". |
Ran into this issue when I wanted to create abbrs with no letter characters.