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

Not enough arguments for -U #154

Open
pro-sumer opened this issue Nov 21, 2023 · 9 comments · May be fixed by #159
Open

Not enough arguments for -U #154

pro-sumer opened this issue Nov 21, 2023 · 9 comments · May be fixed by #159

Comments

@pro-sumer
Copy link

Recently I have been getting this error when trying to reuse commands from my zsh history:

_history-substring-search-end:zle:61: not enough arguments for -U

What am I doing wrong? Or what is broken?

@lixiaoyan
Copy link

same here

@dxrcy
Copy link

dxrcy commented Jan 25, 2024

i get it too. specifically when i type - after pressing an up/down arrow key.
it prints the message and doesn't add a - to the prompt, but everything works after that, and typing another - works as expected. until the next up/down arrow key.

@dxrcy dxrcy linked a pull request Jan 26, 2024 that will close this issue
@aperum
Copy link

aperum commented Feb 15, 2024

The proposed fix only fixes the - case for me but not the <space> case which is much more annoying to me ;)
Additionally quoting the argument helps:

--- a/zsh-history-substring-search.zsh
+++ b/zsh-history-substring-search.zsh
@@ -406,7 +406,7 @@ _history-substring-search-end() {

   # For debugging purposes:
   # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
-  # read -k -t 200 && zle -U $REPLY
+  # read -k -t 200 && zle -U -- "$REPLY"

   #
   # When this function returns, z-sy-h runs its line-pre-redraw hook. It has no
@@ -421,7 +421,7 @@ _history-substring-search-end() {
     # before removing search highlight and exiting. This ensures no highlights
     # are left lingering after search is finished.
     #
-    read -k -t ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT:-1} && zle -U $REPLY
+    read -k -t ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT:-1} && zle -U -- "$REPLY"
     region_highlight=( "${(@)region_highlight:#*${highlight_memo}*}" )
   fi

@dxrcy
Copy link

dxrcy commented Feb 16, 2024

Can you explain how to reproduce the <space> case?

This change looks good regardless.

@aperum
Copy link

aperum commented Feb 16, 2024

Just like the - case, press arrow up and then the space key. I get the same error as with -.
I thought this was just another symptom of the same thing as with -. But after your question I investigated further with a minimal config and it seems the culprit is setopt SH_WORD_SPLIT. I added that years ago for compatability reasons.
Maybe the plugin could unset that option for itself so that the users config does not interfere with its functionality.

@dxrcy
Copy link

dxrcy commented Feb 18, 2024

I see. It seems that quoting the variable fixes it regardless, so I don't think we will need to unset SH_WORD_SPLIT.

@xeruf
Copy link

xeruf commented Feb 28, 2024

is the fix on its way? The error is quite obnoxious 😅

@dxrcy
Copy link

dxrcy commented Feb 28, 2024

@xeruf This will be fixed when #159 is merged.
Until then, you can change the package url to github.com/dxrcy/zsh-history-substring-search

@silverwind
Copy link

change the package url to github.com/dxrcy/zsh-history-substring-search

Better to fork that fork again before using for security 😉.

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

Successfully merging a pull request may close this issue.

6 participants