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];
102 my ($c1, $c2) = split('#', $j, 2);
109 .Bd -literal -offset indent -compact
120 # for my $q ( @operations) {
121 # print "\nshort=".$$q{'short'}."\n";
122 # print "name=".$$q{'name'}."\n";
123 # print "desc=".$$q{'description'}."\n";
124 # if (defined($$q{'alias'})) {
125 # print "alias=".join(',',@{ $$q{'alias'}})."\n";
145 push @functions, " Fl ".$$q{'short'} if defined($$q{'short'});
146 push @functions, " ".long2nroff($$q{'name'});
147 push @functions, join(' ', '', map {long2nroff $_} @{ $$q{'alias'} })
148 if defined($$q{'alias'});
149 $r .= join(' ,', @functions);
150 if (defined($$q{'operand'})) {
151 if ($#functions > 0) {
156 $r .= "Ar ".$$q{'operand'};
158 $r .= "\n".$$q{'description'}."\n";
167 my $k = $$h{'short'};
168 $k = $$h{'name'} if !defined($k);
170 if ($l =~ s/^no-//) {
178 my ($x1, $x2) = optionkeyword($a);
179 my ($y1, $y2) = optionkeyword($b);
180 my $r = lc($x1) cmp lc($y1);
187 @operations = sort optioncmp @operations;
188 @operations = sort optioncmp @operations;
189 @options = sort optioncmp @options;
190 @formats = sort optioncmp @formats;
192 if ($#formats >= 0 && !$saw_format) {
193 print STDERR "FIXME: saw --format=X but no root --format!\n";
197 my $function_letters;
198 my $short_letters = join('', sort @short);
201 my $command_string = <<".";
204 $command_string .= ".Oo Fl Oc";
206 my %env_description = (
207 'SIMPLE_BACKUP_SUFFIX' => <<".",
208 Backup prefix to use when extracting, if
211 The backup suffix defaults to `~' if neither is specified.
214 Device or file to use for the archive if
217 If this environment variable is unset, use stdin or stdout instead.
219 'TAR_OPTIONS' => <<".",
220 Options to prepend to those specified on the command line, separated by
221 whitespace. Embedded backslashes may be used to escape whitespace or
222 backslashes within an option.
226 for my $q ( @operations) {
227 $command_string .= " Cm";
228 $command_string .= $sep;
229 $command_string .= " ".$$q{'short'} if defined($$q{'short'});
230 $command_string .= " ".long2nroff($$q{'name'});
231 if (defined($$q{'alias'})) {
232 my $t = join(' ', '', map{long2nroff $_} @{ $$q{'alias'} });
234 $command_string .= $t;
238 $function_letters = ".Bl -tag -width flag\n";
239 $function_letters .= format_options(\@operations);
240 $function_letters .= ".El";
241 if ($#formats >= 0) {
242 $format_letters = ".Bl -tag -width flag\n";
243 $format_letters .= format_options(\@formats);
244 $format_letters .= ".El\n";
245 $$saw_format{'extra'} = $format_letters;
247 ### Ar Cm Ic Li Nm Op Pa Va
248 $option_letters = ".Bl -tag -width flag\n";
249 $option_letters .= format_options(\@options);
250 $option_letters .= ".El";
251 $env_variables .= ".Bl -tag -width Ds\n";
252 for my $q ( @env_vars) {
253 $env_variables .= ".It Ev $q\n";
254 $env_variables .= $env_description{$q};
256 $env_variables .= ".El";
258 $examples =~ s/\n$//;
259 $function_letters =~ s/\n$//;
260 $option_letters =~ s/\n$//;
261 $env_variables =~ s/\n$//;
263 .\\" generated by script on $t
268 .Nd The GNU version of the tar archiving utility
275 stores and extracts files from a tape or disk archive.
277 The first argument to
279 should be a function; either one of the letters
281 or one of the long function names.
282 A function letter need not be prefixed with ``\\-'', and may be combined
283 with other single-letter options.
284 A long function name must be prefixed with
286 Some options take a parameter; with the single-letter form
287 these must be given as separate arguments.
288 With the long form, they may be given by appending
298 The behavior of tar is controlled by the following environment variables,
315 The GNU folks, in general, abhor man pages, and create info documents instead.
316 Unfortunately, the info document describing tar is licensed under the GFDL with
317 invariant cover texts, which makes it impossible to include any text
318 from that document in this man page.
319 Most of the text in this document was automatically extracted from the usage
321 It may not completely describe all features of the program.