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
2 tasks done
Chekote opened this issue May 15, 2024 · 5 comments
Open
2 tasks done
Labels

Comments

@Chekote
Copy link

Chekote commented May 15, 2024

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
Copy link
Owner

olets commented May 15, 2024

Thanks for the report!

I'm able to replicate this. Added breaking tests in the new branch  118-caret  edit: now named118-failed-erasure edit: now named issues/118. The caret ^ is the source of the problem. Possible they'll have to be disallowed. For now, a workaround is to not use carets in abbreviations.

- $ abbr a^='echo "Do something"'
+ $ abbr a='echo "Do something"'

You'll need to manually delete the a^ abbreviation from the user abbreviations file (see #119)

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

Chekote commented May 16, 2024

Thanks for the quick response ❤️

This also happens with the exclamation mark. I am migrating from Fish to Zsh, and these are the abbreviations that I have set up from Fish. If at all possible, it would be ideal if these could be supported so I don't have to retrain my dumb brain 😆

Thanks for updating the title. I got confused by the output of abbr and thought Added the regular user abbreviation said Added the regular expression abbreviation. My dumb brain assumes "regular" is always followed by "expression" 🤦

@Chekote
Copy link
Author

Chekote commented May 16, 2024

I just discovered something interesting:

If I add the following abbreviation:

abbr dcr!='docker container run --rm'

It ends up in the user file as:

abbr "dcr\!"="docker container run --rm"

Which doesn't expand properly in the shell. But if I edit the user file to remove the backslash:

abbr "dcr!"="docker container run --rm"

Then it works as expected.

But if I add another abbreviation via the abbr command, it adds the backslash back in.

@olets
Copy link
Owner

olets commented May 16, 2024

If at all possible, it would be ideal if these could be supported so I don't have to retrain my dumb brain

I hear that!

Will look into the caret. But heads up that it'll be at least a few days before I have time to investigate, maybe longer.

This also happens with the exclamation mark.

Good find! I can replicate. Updating the title and adding a failing test

I just discovered something interesting [escaped exclamation point]

But if I add another abbreviation via the abbr command, it adds the backslash back in.

Expected, that's because the full file is rewritten.

Thanks for updating the title

No worries! I don't feel users should have to use or know jargon.

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants