From e18667a9a17d7db0b480426311ad0fe911c26dc3 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 20 Nov 2023 06:46:16 +0900 Subject: [PATCH] fix(perl): fix ineffective condition in an awk script The condition `$NF=2` in the awk script actually assigns a value `2` to the last field instead of comparing it to `2` and always evaluates to true. I suspect it to be `NF >= 2`. This could possibly be intended as `NF == 2` or `$NF == 2`, but neither seems to work correctly. The input contains the names of man entries of the form ` perlxx `, but the description is usually given by more than one words, so restricting them by `NF == 2` would be unreasonable. On the other hand, there are no entries ending with the word `2` so `$NF == 2` would produce no results. This condition was introduced from the beginning when the related code was introduced in commit 4254f3a4. There does not seem to be any hints on the background of `$NF=2`. --- completions/perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/perl b/completions/perl index 0938d736ae3..f4eebd4fff4 100644 --- a/completions/perl +++ b/completions/perl @@ -132,7 +132,7 @@ _comp_cmd_perldoc() if [[ $cur == p* ]]; then _comp_compgen -a split -- "$(PERLDOC_PAGER=cat "$1" -u perl | command sed -ne '/perl.*Perl overview/,/perlwin32/p' | - awk '$NF=2 && $1 ~ /^perl/ { print $1 }')" + awk 'NF >= 2 && $1 ~ /^perl/ { print $1 }')" fi fi _comp_compgen -a filedir 'p@([lm]|od)'