This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove ill-designed %B introduced by change #4111.
[perl5.git] / pod / podchecker.PL
1 #!/usr/local/bin/perl
2
3 use Config;
4 use File::Basename qw(&basename &dirname);
5
6 # List explicitly here the variables you want Configure to
7 # generate.  Metaconfig only looks for shell variables, so you
8 # have to mention them as if they were shell variables, not
9 # %Config entries.  Thus you write
10 #  $startperl
11 # to ensure Configure will look for $Config{startperl}.
12
13 # This forces PL files to create target in same directory as PL file.
14 # This is so that make depend always knows where to find PL derivatives.
15 chdir(dirname($0));
16 ($file = basename($0)) =~ s/\.PL$//;
17 $file =~ s/\.pl$//
18         if ($^O eq 'VMS' or $^O eq 'os2');  # "case-forgiving"
19
20 open OUT,">$file" or die "Can't create $file: $!";
21
22 print "Extracting $file (with variable substitutions)\n";
23
24 # In this section, perl variables will be expanded during extraction.
25 # You can use $Config{...} to use Configure variables.
26
27 print OUT <<"!GROK!THIS!";
28 $Config{'startperl'}
29     eval 'exec perl -S \$0 "\$@"'
30         if 0;
31 !GROK!THIS!
32
33 # In the following, perl variables are not expanded during extraction.
34
35 print OUT <<'!NO!SUBS!';
36 #############################################################################
37 # podchecker -- command to invoke the podchecker function in Pod::Checker
38 #
39 # Derived from Tom Christiansen's pod2text script.
40 # (with extensive modifications)
41 #
42 # Copyright (c) 1998 Bradford Appleton. All rights reserved.
43 # This file is part of "PodParser". PodParser is free software;
44 # you can redistribute it and/or modify it under the same terms
45 # as Perl itself.
46 #############################################################################
47
48 use strict;
49 use diagnostics;
50
51 =head1 NAME
52
53 podchecker - check the syntax of POD format documentation files
54
55 =head1 SYNOPSIS
56
57 B<podchecker> [B<-help>] [B<-man>] [I<file>S< >...]
58
59 =head1 OPTIONS AND ARGUMENTS
60
61 =over 8
62
63 =item B<-help>
64
65 Print a brief help message and exit.
66
67 =item B<-man>
68
69 Print the manual page and exit.
70
71 =item I<file>
72
73 The pathname of a POD file to syntax-check (defaults to standard input).
74
75 =back
76
77 =head1 DESCRIPTION
78
79 B<podchecker> will read the given input files looking for POD
80 syntax errors in the POD documentation and will print any errors
81 it find to STDERR. At the end, it will print a status message
82 indicating the number of errors found.
83
84 B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
85 Please see L<Pod::Checker/podchecker()> for more details.
86
87 =head1 SEE ALSO
88
89 L<Pod::Parser> and L<Pod::Checker>
90
91 =head1 AUTHOR
92
93 Brad Appleton E<lt>bradapp@enteract.comE<gt>
94
95 Based on code for B<Pod::Text::pod2text(1)> written by
96 Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
97
98 =cut
99
100
101 use Pod::Checker;
102 use Pod::Usage;
103 use Getopt::Long;
104
105 ## Define options
106 my %options = (
107         "help"     => 0,
108         "man"      => 0,
109 );
110
111 ## Parse options
112 GetOptions(\%options, "help", "man")  ||  pod2usage(2);
113 pod2usage(1)  if ($options{help});
114 pod2usage(-verbose => 2)  if ($options{man});
115
116 ## Dont default to STDIN if connected to a terminal
117 pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
118
119 ## Invoke podchecker()
120 if(@ARGV) {
121    for (@ARGV) { podchecker($_) };
122 } else {
123         podchecker("<&STDIN");
124 }
125
126 !NO!SUBS!
127
128 close OUT or die "Can't close $file: $!";
129 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
130 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';