-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[bash,zsh] Improve the AWK compatibility #4412
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
Conversation
macOS awk is a variant of nawk, but it contains a unique patch for the UTF-8 support. However, this patch causes the problem. If the input contains any non-UTF-8 data, macOS awk stops processing and does not do anything, instead of ignoring the unrecognized data and continue the processing. However, the contents of the ssh configuration and /etc/hosts is not under the control of fzf, so we cannot fix the input when those files contain non-UTF-8 data. To work around this behavior, one can set the locale to LC_ALL=C to treat the input data with the plain 8-bit encoding.
Solaris awk at /usr/bin/awk is meant for backward compatibility with an ancient implementation of 1977 awk in the original UNIX. It lacks many features of POSIX awk. To use a standard-conforming version in Solaris, one needs to explicitly use /usr/xpg4/bin/awk.
No, there isn't one currently. These days, we recommend users to use the output of
Yeah, that's unfortunate, especially because I like what you did here. But most of the lines are comments, so I don't think it's too bad. Anyway, I don't recall getting a bug report about awk compatibility in the past few years unlike in your case, so the number of users who would benefit from this is probably quite small? How was your experience? |
I'm not sure if you like it, but I added commit 9d8feb6 to maintain the common shell functions (i.e.,
Maybe the situation is different from the Fzf project, but in my project ( Another thing is related to whether we really need to take care of the bugs and quirks of the external tools. Ideally, they should be fixed at the upstream Nevertheless, some AWK compatibility issues exist in the
|
It's a nice touch, thanks. And I really appreciate the detailed explanation. |
9d8feb6
to
766f4ea
Compare
766f4ea
to
2ba3f60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good. Thanks. Is there anything else you want to address?
Thanks! I checked it once again. If you like it, I'm fine with merging the PR in its current state. |
Merged, thanks! |
This PR adds some workarounds for bugs and quirks of
awk
implementations. Details are described in the respective commit messages.Shell function shared by four files
To implement this, I added a function
__fzf_exec_awk
, but I needed to copy this function to all{complete,key-bindings}.{zsh,bash}
(just like the existing__fzf_defaults
). However, it might not be useful. When modifying the function in the future, one needs to update all the four files at the same time. Also, the size of copied lines becomes large. Is there an existing policy about how to process this situation? If you want to introduce a mechanism to automatically update the copied part of the files or to introduce a mechanism to generate the final form of the files from templates, I'm not reluctant to implement it.edit: Ref. #4407 (comment)