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. |
| 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.
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.
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.
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]
endI 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.