Skip to content

Commit 302dc52

Browse files
committed
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 <description>`, 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 4254f3a. There does not seem to be any hints on the background of `$NF=2`.
1 parent cdd6da9 commit 302dc52

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

completions/perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ _comp_cmd_perldoc()
132132
if [[ $cur == p* ]]; then
133133
_comp_compgen -a split -- "$(PERLDOC_PAGER=cat "$1" -u perl |
134134
command sed -ne '/perl.*Perl overview/,/perlwin32/p' |
135-
awk '$NF=2 && $1 ~ /^perl/ { print $1 }')"
135+
awk 'NF >= 2 && $1 ~ /^perl/ { print $1 }')"
136136
fi
137137
fi
138138
_comp_compgen -a filedir 'p@([lm]|od)'

0 commit comments

Comments
 (0)