-
-
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
[shell] improve mawk detection #3463
Conversation
* Use the all-compatible mawk `-W version` option. junegunn#3313 (comment). * Do not remap the history key if no dependent commands is installed (perl, awk or mawk in this order). * Run the command and not a function consistently with junegunn#3462. The version check bash code relies on the following mawk source code, extracted from mawk 1.3.4 20230322. ``` version.c: 18- #include "init.h" 19- #include "patchlev.h" 20- 21: #define VERSION_STRING \ 22- "mawk %d.%d%s %s\n\ 23- Copyright 2008-2022,2023, Thomas E. Dickey\n\ 24- Copyright 1991-1996,2014, Michael D. Brennan\n\n" .... 30- void 31- print_version(FILE *fp) 32- { 33: fprintf(fp, VERSION_STRING, PATCH_BASE, PATCH_LEVEL, PATCH_STRING, DATE_STRING); 34- fflush(fp); 35- 36- #define SHOW_RANDOM "random-funcs:" patchlev.h: 13- /* 14- * $MawkId: patchlev.h,v 1.128 2023/03/23 00:23:57 tom Exp $ 15- */ 16: #define PATCH_BASE 1 17- #define PATCH_LEVEL 3 18- #define PATCH_STRING ".4" 19- #define DATE_STRING "20230322" ```
Other than the comments made in the code above, I think it looks mostly good, I especially like that you saved at least one execution of
I checked it on Debian with |
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.
Trying to remove unnecessary diffs.
I also think it's unnecessary. The absence of awk can be a sign of a broken system, and we should probably warn the user with an error instead of silently disabling a subset of our feature, making it harder to fix the system. |
Merged, thanks! |
Looks good to me, though I probably still have placed the |
Oh, one more thing that I had noticed before, but forgot to write down: Line 75 in 8848560
Wouldn't it be safer to use |
-W version
option. replace awk for perl in the bash history widget #3313 (comment).command
to “protect” further commands #3462.The version check bash code relies on the following mawk source code, extracted from mawk 1.3.4 20230322.