-
Notifications
You must be signed in to change notification settings - Fork 20
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
!
is escaped in v5, but wasn’t in v4
#84
Comments
Thanks for the report and the kind words. Glad the plugin is useful for you! I can reproduce both the reported v4 behavior and the reported v5 behavior. And thanks for looking into the history. My guess is it's actually somewhere in but it's good to be reminded that there were additional commits in support of multi-word abbreviations after that PR (that work was a while back!). I think it's very likely that you're right and the change in quote levels is the cause. Work and life are busy right now. I'm not going to commit to a timeline but I do want to see this solved! In the meantime, downgrading might be a solution for you https://zsh-abbr.olets.dev/migrating-between-versions.html#downgrading-v5-to-v4 -- If you or someone else is interested in helping out, let me know. The quoting is touchy, and a change will impact several commands. Imo it'd be okay if the v5 solution does require writing expansions differently from how they were written in v4. |
@LucasLarson I recently started a policy of listing as part of the "community" reporters of legitimate bugs (https://zsh-abbr.olets.dev/community/; #83). Would you like to be added? |
I’m determined to stay on the bleeding edge – to remain on version 5 – but I would like to mention that
Sounds great – thank you! In the meantime, I might get by with something appalling like so: alias -g srn='
printf -- '\''sed -e '\''\'\'''\'':a'\''\'\'''\'' -e '\''\'\'''\''N'\''\'\'''\'' -e '\''\'\'''\''\044\041 b a'\''\'\'''\'' -e '\''\'\'''\''s/\\n//g'\''\'\'''\'''\''\\n 2>/dev/null;
printf -- '\''sed -e '\''\'\'''\'':a'\''\'\'''\'' -e '\''\'\'''\''N'\''\'\'''\'' -e '\''\'\'''\''\044\041 b a'\''\'\'''\'' -e '\''\'\'''\''s/\\n//g'\''\'\'''\'''\'' | pbcopy
' |
@all-contributors please add @LucasLarson for bug |
I've put up a pull request to add @LucasLarson! 🎉 |
Spent some time on this. No solve yet, and I'm still busy so won't return to it for a while. Not a safe solution for everyone, but @LucasLarson this might work for you… as long as you rarely need to type a command with # in zshrc
custom-abbr-expand-and-space() {
abbr-expand-and-space
LBUFFER=${LBUFFER:gs/\\!/!} # replace all `\!` with `!`
}
zle -N custom-abbr-expand-and-space
bindkey " " custom-abbr-expand-and-space # must be *after* loading zsh-abbr -- For future reference: found this, which may point in the right direction: % abbr exclamation=!
% cat $ABBR_USER_ABBREVIATIONS_FILE | grep exclamation
abbr "exclamation"="\!"
% abbr | grep exclamation
"exclamation"="\\\!"
% abbr other=other
% cat $ABBR_USER_ABBREVIATIONS_FILE | grep exclamation
abbr "exclamation="\\!" |
This workaround is great – thank you! Thanks also for adding more breadcrumbs. |
this version of the command: - uses no exclamation point (`!`),¹ obviating the need to modify `$LBUFFER`² - escapes a newline (`\n` is saved here as `\\n`)³ so that when printed to the console, the newline recipe appears correctly as `\n`⁴ rather than as a mid-command linebreak⁵ --- 1. `sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'` performs the same task, but uses an exclamation point (`!`), which requires modifying `$LBUFFER`² 2. olets/zsh-abbr#84 (comment) 3. `abbr -g "sed -n 'H;${x;s/\\n//gp;}'"` 4. ` sed -n 'H;${x;s/\n//gp;}'` 5. ` sed -n 'H;${x;s/⏎//gp;}'` Signed-off-by: Lucas Larson <[email protected]>
this version of the command: - uses no exclamation point (`!`),¹ obviating the need to modify `$LBUFFER`² - escapes a newline (`\n` is saved here as `\\n`)³ so that when printed to the console, the newline recipe appears correctly as `\n`⁴ rather than as a mid-command linebreak⁵ --- 1. `sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'` performs the same task, but uses an exclamation point (`!`), which requires modifying `$LBUFFER`² 2. olets/zsh-abbr#84 (comment) 3. `abbr -g "sed -n 'H;${x;s/\\n//gp;}'"` 4. ` sed -n 'H;${x;s/\n//gp;}'` 5. ` sed -n 'H;${x;s/⏎//gp;}'` Signed-off-by: Lucas Larson <[email protected]>
this version of the command: - uses no exclamation point (`!`),¹ obviating the need to modify `$LBUFFER`² - escapes a newline (`\n` is saved here as `\\n`)³ so that when printed to the console, the newline recipe appears correctly as `\n`⁴ rather than as a mid-command linebreak⁵ --- 1. `sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'` performs the same task, but uses an exclamation point (`!`), which requires modifying `$LBUFFER`² 2. olets/zsh-abbr#84 (comment) 3. `abbr -g "sed -n 'H;${x;s/\\n//gp;}'"` 4. ` sed -n 'H;${x;s/\n//gp;}'` 5. ` sed -n 'H;${x;s/⏎//gp;}'` Signed-off-by: Lucas Larson <[email protected]>
this version of the command: - uses no exclamation point (`!`),¹ obviating the need to modify `$LBUFFER`² - escapes a newline (`\n` is saved here as `\\n`)³ so that when printed to the console, the newline recipe appears correctly as `\n`⁴ rather than as a mid-command linebreak⁵ --- 1. `sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'` performs the same task, but uses an exclamation point (`!`), which requires modifying `$LBUFFER`² 2. olets/zsh-abbr#84 (comment) 3. `abbr -g "sed -n 'H;${x;s/\\n//gp;}'"` 4. ` sed -n 'H;${x;s/\n//gp;}'` 5. ` sed -n 'H;${x;s/⏎//gp;}'` Signed-off-by: Lucas Larson <[email protected]>
I encountered a similar issue, when trying to create an abbreviation for
When trying the workaround, the message This abbreviation is similar to |
@qadzek thanks for reporting. To clarify, does deleting
Always interested to hear the different ways people use abbreviations. What's the context where you want to follow sbb with no space and more text? |
Thanks for your reply.
It looks like the Besides using custom-abbr-expand-and-enter() {
abbr-expand-and-accept
LBUFFER=${LBUFFER:gs/\\!/!} # replace all `\!` with `!`
}
zle -N custom-abbr-expand-and-enter
bindkey "^M" custom-abbr-expand-and-enter # must be *after* loading zsh-abbr |
This is unrelated to this issue and I am unsure if this is expected behavior or a bug. After setting |
Oh I see yes I forgot about that snippet.
That's the right fix. Too late to be useful for you, but I've pushed an update (752e9fc) so that the deprecation warning says to use
That's a bug! Thanks for catching it. The immediate workaround is to choose a different cursor marker. zsh treats |
Is there an existing issue for this?
Update the issue title
Expected Behavior
open a terminal window and load this amazing plugin and then enter s then r then n then space:
$ srn
...and have it transformed as it was in v4:
$ sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'
Actual Behavior
the text is transformed into the following since v5 (the escaped exclamation point is new)
$ sed -e ':a' -e 'N' -e '$\! b a' -e 's/\n//g'
Steps To Reproduce
printf \\41
. Here’s some examples I can’t force to work no matter the means I use to try and hide the!
from zsh-abbr and zsh: try filling your$ABBR_USER_ABBREVIATIONS_FILE
with the following, all of which worked fine in v4find
wherefind . \! -path xyz
andfind . ! -path xyz
are interpreted as the same command. It does however break an already-escaped exclamation pointwhich expands into the following, which includes a literal newline:
Environment
Installation method
Manual
Installation method details
No response
Anything else?
Pretty sure the problem begins in either
30216ba7ba
or2503546976
.Thank you for this solid, serious, well-documented plugin.
The text was updated successfully, but these errors were encountered: