-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
remove perl dependency for bash #1934
Conversation
Please make sure that the existing tests all pass. ( |
OK, both sed and awk can do this
or
One problem is sed -z option is only available version 4.2.2+ which released at Sat, 22 Dec 2012
|
Then we can't use it, macOS Catalina ships with old BSD sed (2005). $ sed -z
sed: illegal option -- z |
@@ -290,7 +290,7 @@ d_cmds="${FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}" | |||
a_cmds=" | |||
awk cat diff diff3 | |||
emacs emacsclient ex file ftp g++ gcc gvim head hg java | |||
javac ld less more mvim nvim patch perl python ruby | |||
javac ld less more mvim nvim patch python ruby |
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.
This is unrelated.
gensub is not available for BSD awk on mac os, just hold on, I'll find a better solution |
Yeah, thanks. Is there a reason you want to remove perl dependency? Perl is available on virtually every Unixy system nowadays. |
This reverts commit 6ee71be.
I‘ve tested awk with sub function works well on mac OS and passed docker-test, you can review now. The reason is I want to use fzf in docker container and |
While it works with GNU awk, which can be installed using Homebrew ( |
Yes, you are right. |
Thanks, but I'm not a fan of this code branch. (FYI, we rely on Perl even more since 18261fe) Minimizing dependency is nice, but I'd just use Perl in this case as I don't want to increase code complexity and I don't think it's too much to require Perl on interactive command-line environments.
That's a valid point but such Docker images are mainly for building lightweight containers rather than interactive command-line environments. So I think it's forgivable that interactive fzf scripts don't work in those images out of the box without additional installation steps. Perl on Alpine is quite small, so I suggest that you just install Perl when you build your Docker containers. |
While awk is POSIX, perl isn't pre-installed on all *nix flavors. This commit replaces perl with awk thus it eliminates the perl dependency. This commit passed the current test suite with zero errors : * `make error` => all test sections 'ok' * `make docker-test` => Finished in 50.929904s, 4.1822 runs/s, 35.3427 assertions/s. 213 runs, 1800 assertions, 0 failures, 0 errors, 0 skips See also: junegunn#2777 junegunn#1934 # junegunn#3077 junegunn#2260 Note: unlike the original perl script, which gets `$HISTCOUNT` from the environment, the awk script reads the initial history count from line 1 of stdin. Then follow the history list, and finally a `\t`. The reason for `\t` is to fix a small, pre-existing issue I noticed while developing this patch (see the PR associated with this commit for additional information).
refer to #1931
juse use builtin histtory and sort by reverse order, and use sed and tr to replace perl