]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
badwords: pass config as filename arg
authorViktor Szakats <commit@vsz.me>
Tue, 17 Mar 2026 23:51:08 +0000 (00:51 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 18 Mar 2026 10:22:23 +0000 (11:22 +0100)
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
scripts/badwords-all

index 7a62d543f5dc20888f871577e507226205f89c91..3f9cb46d8d0478a53b61f221defe8bd83b1a4dd0 100755 (executable)
@@ -174,7 +174,9 @@ my %wl;
 
 my @w;
 my @exact;
-while(<STDIN>) {
+my $file = shift @ARGV;
+open(CONFIG, "<$file") or die "Cannot open '$file': $!";
+while(<CONFIG>) {
     chomp;
     if($_ =~ /^#/) {
         next;
@@ -200,6 +202,7 @@ while(<STDIN>) {
         }
     }
 }
+close(CONFIG);
 
 # Build a single combined regex for case-insensitive words
 my $re_ci;
index 27beba2596ad7787f3d92c09bbd0bb1d2297a1f7..3face08ba1a82aa4249f7261f840cf1b34a21db8 100755 (executable)
@@ -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;