-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add string tokenize builtin command #3823
Comments
The initial description could use more details. I searched the fzf issues and couldn't find anything relevant. Will fzf actually use such a feature? In any event we've received a couple of questions in the recent past for how to produce tokens from a command line in the same way fish does internally. I recall one answer was to abuse |
Please do not implement this until a firm design proposal is written. @faho and I just had a conversation on Gitter about the somewhat surprising behavior of |
@krader1961 and I have just discussed some questionable behavior of Specifically,
The questions are:
I'd argue that ignoring "non-string" tokens is inherently broken, and causes anything that relies on it to be broken as well. |
Note that you can trivially explore the current tokenize behavior. Run
Then type various commands that include pipes, semicolons, quoted strings, subcommands, etc. and press [ctrl-T] to see how what you have typed is tokenized. |
My recommendation is to leave the current |
@faho @ridiculousfish are we ditching |
I still want to. It's a terrible interface. |
So, I now have a branch that implements It keeps "special" tokens like redirections and pipes, so you should get a fairly complete representation of the string. It doesn't go into command substitutions, because our tokenizer itself doesn't. It uses the But I'm not sure if that's the right way around or useful at all, because I'm not quite sure what this is used for. I know there was one case where I hacked a completion or binding to set Essentially if you keep the quotes, you can know that it had quotes (useful for the magic paste stuff, I'd imagine). If you strip them, you can more easily pass it to a second |
This splits a string into variables according to the shell's tokenization rules, considering quoting, escaping etc. This runs an automatic `unescape` on the string so it's presented like it would be passed to the command. E.g. printf '%s\n' a\ b returns the tokens printf %s\n a b It might be useful to add another mode "--tokenize-raw" that doesn't do that, but this seems to be the more useful of the two. Fixes fish-shell#3823.
Output tokenized history commands. This is useful for tools like fzf to do further filtering and completion.
implemented in #3818 .
The text was updated successfully, but these errors were encountered: