Skip to content
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

[Bug report] Cannot programmatically delete abbreviations containing certain characters #118

Open
4 of 7 tasks
Chekote opened this issue May 15, 2024 · 7 comments
Open
4 of 7 tasks
Labels
bug Something isn't working help welcome

Comments

@Chekote
Copy link

Chekote commented May 15, 2024

@olets's maintainer edit: this generalized into several bugs related. Summarizing here.

erase outputs a success message but doesn't actually delete if the abbreviation contains

  • a caret (^) (original report)
  • a hash symbol (#)
  • an exclamation point (!)
  • double quotation marks (")
  • single quotation marks (')

For the ones not checked off, read #118 (comment) for workarounds.

Original report follows…


 
 
 
 

Is there an existing issue for this?

  • I have searched the existing issues

Update the issue title

  • I have updated the title

Expected Behavior

The abbreviation should be deleted.

Actual Behavior

zsh-abbr claims the abbreviation was deleted, but it is not.

Steps To Reproduce

  1. Add the abbreviation:
$ abbr a^='echo "Do something"'
Added the regular user abbreviation `a^`
  1. Run the abbreviation:
$ a^
  1. Notice the abbreviation runs as expected.
$ echo "Do something"
Do something
  1. Delete the abbreviation:
$ abbr e a^
Erased regular user abbreviation `a^`
  1. Try to run the abbreviation
$ a^
  1. Notice that it runs, even those zsh-abbr claimed it was erased.
$ echo "Do something"
Do something

Environment

zsh-abbr version 5.4.1
zsh 5.9 (x86_64-apple-darwin23.0)
OSTYPE darwin23.0

Installation method

Homebrew

Installation method details

Homebrew 4.3.0-20-g1f603d3

Anything else?

No response

@olets olets added bug Something isn't working under consideration and removed needs triage labels May 15, 2024
@olets

This comment has been minimized.

@olets olets changed the title [Bug report] Cannot delete regular expression abbreviations [Bug report] Cannot delete abbreviation containing a caret (^) May 15, 2024
@Chekote

This comment has been minimized.

@Chekote

This comment has been minimized.

@olets

This comment has been minimized.

@olets olets changed the title [Bug report] Cannot delete abbreviation containing a caret (^) [Bug report] Cannot programmatically delete abbreviations containing a caret (^) or exclamation point (!) May 16, 2024
@olets olets changed the title [Bug report] Cannot programmatically delete abbreviations containing a caret (^) or exclamation point (!) [Bug report] Cannot programmatically delete abbreviations containing certain characters Jun 11, 2024
@olets
Copy link
Owner

olets commented Jun 11, 2024

Abbreviations with quotation marks also can't be deleted.

Looks relevant https://unix.stackexchange.com/a/626529/248959

@olets olets added this to zsh-abbr Jul 29, 2024
@olets olets moved this to Nice To Have in zsh-abbr Jul 29, 2024
@olets olets removed the status in zsh-abbr Jul 29, 2024
@olets olets moved this to Nice To Have in zsh-abbr Jul 29, 2024
@olets olets moved this from Nice To Have to Todo in zsh-abbr Jul 29, 2024
@olets olets moved this from Todo to In Progress in zsh-abbr Jul 29, 2024
olets added a commit that referenced this issue Jul 31, 2024
add failing tests for erasure limitations [#118]
@scottyeager

This comment has been minimized.

@olets
Copy link
Owner

olets commented Feb 10, 2025

v6.1.0

  • fixes abbr erase to work with abbreviations containing a caret ^ (cc @Chekote) and abbreviations containing a hash symbol # (cc @scottyeager)
  • fixes expansion to support abbreviations containing exclamation points (cc @Chekote)

Thanks again for reporting

//

Going to hide most of the comments in this issue as "resolved" but leaving this open because there's still a little goofiness in erase:

  • to erase an abbreviation containing an exclamation point, single quote the abbreviation and double-escape the exclamation point(s):
     abbr 'abc!'=d
     abbr erase 'abc\\!'
  • to erase an abbreviation containing double quotes, single quote the abbreviation and escape the quotation mark(s):
     abbr 'a"b"c'=d
     abbr erase 'a\"b\"c'

There are failing tests for those in the branch issues/118 if anyone reading this wants to work on a fix.

As always, can manually delete the abbreviation by editing ABBR_USER_ABBREVIATIONS_FILE and then running exec zsh or abbr load.

Or use a session abbreviation (abbr -S 'abc!') for abbreviations you know you'll erase soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help welcome
Projects
Status: In Progress
Development

No branches or pull requests

3 participants