2 # tarman - make tar man page from src/tar.c
3 # some text cribbed from debian tar man page
8 my $t = "".localtime(time);
9 my $datestr = substr($t,4,3)." ".substr($t,8,2).", ".substr($t,20,4);
24 # print "$mode: $_\n";
26 next if defined($mode);
29 push @env_vars, $c1[1];
32 if (/Main operation mode:/) {
36 if (/Operation modifiers:/) {
52 if ($mode == 1 || $mode == 2) {
55 my @c1 = split('"', $j[0]);
57 next unless defined($lastoperation);
58 push @{$$lastoperation{'alias'} }, $c1[1];
62 $lastoperation = \%newhash;
65 $name =~ s/^ */format=/;
66 push @formats, $lastoperation;
67 } elsif ($mode == 1) {
68 push @operations, $lastoperation;
70 push @options, $lastoperation;
72 $newhash{'name'} = $name;
73 if ($mode == 2 && $name eq 'format') {
74 $saw_format = $lastoperation;
76 my @c2 = split("'", $j[1]);
78 $newhash{'short'} = $c2[1];
79 push @short, $c2[1] if ($mode == 1);
86 next unless defined($lastoperation);
89 my @c3 = split('"', $nrest);
92 $$lastoperation{'operand'} .= $c3[1];
94 $$lastoperation{'description'} .= $c3[1];
97 if (!$nflag && !/\}/) {
99 my @extended_desc = split('"', $_);
100 $$lastoperation{'description'} .= $extended_desc[1];
111 my ($c1, $c2) = split('#', $j, 2);
118 .Bd -literal -offset indent -compact
129 # for my $q ( @operations) {
130 # print "\nshort=".$$q{'short'}."\n";
131 # print "name=".$$q{'name'}."\n";
132 # print "desc=".$$q{'description'}."\n";
133 # if (defined($$q{'alias'})) {
134 # print "alias=".join(',',@{ $$q{'alias'}})."\n";
154 push @functions, " Fl ".$$q{'short'} if defined($$q{'short'});
155 push @functions, " ".long2nroff($$q{'name'});
156 push @functions, join(' ', '', map {long2nroff $_} @{ $$q{'alias'} })
157 if defined($$q{'alias'});
158 $r .= join(' ,', @functions);
159 if (defined($$q{'operand'})) {
160 if ($#functions > 0) {
165 $r .= "Ar ".$$q{'operand'};
167 $r .= "\n".$$q{'description'}."\n";
176 my $k = $$h{'short'};
177 $k = $$h{'name'} if !defined($k);
179 if ($l =~ s/^no-//) {
187 my ($x1, $x2) = optionkeyword($a);
188 my ($y1, $y2) = optionkeyword($b);
189 my $r = lc($x1) cmp lc($y1);
196 @operations = sort optioncmp @operations;
197 @operations = sort optioncmp @operations;
198 @options = sort optioncmp @options;
199 @formats = sort optioncmp @formats;
201 if ($#formats >= 0 && !$saw_format) {
202 print STDERR "FIXME: saw --format=X but no root --format!\n";
206 my $function_letters;
207 my $short_letters = join('', sort @short);
210 my $command_string = <<".";
213 $command_string .= ".Oo Fl Oc";
215 my %env_description = (
216 'SIMPLE_BACKUP_SUFFIX' => <<".",
217 Backup prefix to use when extracting, if
220 The backup suffix defaults to `~' if neither is specified.
223 Device or file to use for the archive if
226 If this environment variable is unset, use stdin or stdout instead.
228 'TAR_OPTIONS' => <<".",
229 Options to prepend to those specified on the command line, separated by
230 whitespace. Embedded backslashes may be used to escape whitespace or
231 backslashes within an option.
235 for my $q ( @operations) {
236 $command_string .= " Cm";
237 $command_string .= $sep;
238 $command_string .= " ".$$q{'short'} if defined($$q{'short'});
239 $command_string .= " ".long2nroff($$q{'name'});
240 if (defined($$q{'alias'})) {
241 my $t = join(' ', '', map{long2nroff $_} @{ $$q{'alias'} });
243 $command_string .= $t;
247 $function_letters = ".Bl -tag -width flag\n";
248 $function_letters .= format_options(\@operations);
249 $function_letters .= ".El";
250 if ($#formats >= 0) {
251 $format_letters = ".Bl -tag -width flag\n";
252 $format_letters .= format_options(\@formats);
253 $format_letters .= ".El\n";
254 $$saw_format{'extra'} = $format_letters;
256 ### Ar Cm Ic Li Nm Op Pa Va
257 $option_letters = ".Bl -tag -width flag\n";
258 $option_letters .= format_options(\@options);
259 $option_letters .= ".El";
260 $env_variables .= ".Bl -tag -width Ds\n";
261 for my $q ( @env_vars) {
262 $env_variables .= ".It Ev $q\n";
263 $env_variables .= $env_description{$q};
265 $env_variables .= ".El";
267 $examples =~ s/\n$//;
268 $function_letters =~ s/\n$//;
269 $option_letters =~ s/\n$//;
270 $env_variables =~ s/\n$//;
272 .\\" generated by script on $t
277 .Nd The GNU version of the tar archiving utility
284 stores and extracts files from a tape or disk archive.
286 The first argument to
288 should be a function; either one of the letters
290 or one of the long function names.
291 A function letter need not be prefixed with ``\\-'', and may be combined
292 with other single-letter options.
293 A long function name must be prefixed with
295 Some options take a parameter; with the single-letter form
296 these must be given as separate arguments.
297 With the long form, they may be given by appending
307 The behavior of tar is controlled by the following environment variables,
324 The GNU folks, in general, abhor man pages, and create info documents instead.
325 Unfortunately, the info document describing tar is licensed under the GFDL with
326 invariant cover texts, which makes it impossible to include any text
327 from that document in this man page.
328 Most of the text in this document was automatically extracted from the usage
330 It may not completely describe all features of the program.