From 650b33a3dbcb6a48dc52f735401bb75f52bc3121 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 18 Mar 2026 00:51:08 +0100 Subject: [PATCH] badwords: pass config as filename arg Instead of stdin. To simplify the command-line, and allow using a safe and portable `system()` call from `badwords-all`. Ref: https://perldoc.perl.org/functions/system Closes #20970 --- scripts/badwords | 5 ++++- scripts/badwords-all | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/badwords b/scripts/badwords index 7a62d543f5..3f9cb46d8d 100755 --- a/scripts/badwords +++ b/scripts/badwords @@ -174,7 +174,9 @@ my %wl; my @w; my @exact; -while() { +my $file = shift @ARGV; +open(CONFIG, "<$file") or die "Cannot open '$file': $!"; +while() { chomp; if($_ =~ /^#/) { next; @@ -200,6 +202,7 @@ while() { } } } +close(CONFIG); # Build a single combined regex for case-insensitive words my $re_ci; diff --git a/scripts/badwords-all b/scripts/badwords-all index 27beba2596..3face08ba1 100755 --- a/scripts/badwords-all +++ b/scripts/badwords-all @@ -8,6 +8,7 @@ use warnings; use File::Basename; -chdir dirname(__FILE__) . "/.."; +chdir dirname(__FILE__) . '/..'; -exit system("scripts/badwords '**.md' projects/OS400/README.OS400 src lib include docs/examples < scripts/badwords.txt") >> 8; +exit system('scripts/badwords', ('scripts/badwords.txt', + '**.md', 'projects/OS400/README.OS400', 'src', 'lib', 'include', 'docs/examples')) >> 8;