]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
scripts/LinuxManBook/prepare.pl: Use more robust pipelines
authorAlejandro Colomar <alx@kernel.org>
Wed, 20 Mar 2024 21:05:08 +0000 (22:05 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 20 Mar 2024 23:03:19 +0000 (00:03 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
scripts/LinuxManBook/prepare.pl

index 735cfcf0935c5efe8ccfa3cad21a8c5d3a6e1595..57b99b717e2847f4879d4ac6cec0c1f222c7c3a1 100755 (executable)
@@ -51,7 +51,9 @@ my %files;
 my %aliases;
 my %target;
 
-foreach my $al (`grep -E '^\\.so' $dir/man*/*`)
+foreach my $al (`find "$dir"/man*/ -type f \\
+               | grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$" \\
+               | xargs grep '^\\.so' /dev/null;`)
 {
        #$al=~tr[.][_];
        $al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*)/o;
@@ -66,8 +68,11 @@ while (my ($k,$v)=each %aliases)
        }
 }
 
-foreach my $fn (glob "$dir/man*/*")
+foreach my $fn (`find "$dir"/man*/ -type f \\
+               | grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$";`)
 {
+       $fn=~s/\n//;
+
        my ($nm,$sec)=GetNmSec($fn,qr/\.\d[a-z]*/);
        $files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}.$sec"];
 }