2 # tarman - make tar man page from src/tar.c
3 # some text cribbed from debian tar man page
7 use POSIX qw(strftime);
9 my $t = $ENV{'BUILD_DATE'} // strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time));
10 my $datestr = substr($t,8,3)." ".substr($t,5,2).", ".substr($t,12,4);
25 # print "$mode: $_\n";
27 next if defined($mode);
30 push @env_vars, $c1[1];
33 if (/Main operation mode:/) {
37 if (/Operation modifiers:/) {
53 if ($mode == 1 || $mode == 2) {
56 my @c1 = split('"', $j[0]);
58 next unless defined($lastoperation);
59 push @{$$lastoperation{'alias'} }, $c1[1];
63 $lastoperation = \%newhash;
66 $name =~ s/^ */format=/;
67 push @formats, $lastoperation;
68 } elsif ($mode == 1) {
69 push @operations, $lastoperation;
71 push @options, $lastoperation;
73 $newhash{'name'} = $name;
74 if ($mode == 2 && $name eq 'format') {
75 $saw_format = $lastoperation;
77 my @c2 = split("'", $j[1]);
79 $newhash{'short'} = $c2[1];
80 push @short, $c2[1] if ($mode == 1);
87 next unless defined($lastoperation);
90 my @c3 = split('"', $nrest);
93 $$lastoperation{'operand'} .= $c3[1];
95 $$lastoperation{'description'} .= $c3[1];
98 if (!$nflag && !/\}/) {
100 my @extended_desc = split('"', $_);
101 $$lastoperation{'description'} .= $extended_desc[1];
112 my ($c1, $c2) = split('#', $j, 2);
119 .Bd -literal -offset indent -compact
130 # for my $q ( @operations) {
131 # print "\nshort=".$$q{'short'}."\n";
132 # print "name=".$$q{'name'}."\n";
133 # print "desc=".$$q{'description'}."\n";
134 # if (defined($$q{'alias'})) {
135 # print "alias=".join(',',@{ $$q{'alias'}})."\n";
155 push @functions, " Fl ".$$q{'short'} if defined($$q{'short'});
156 push @functions, " ".long2nroff($$q{'name'});
157 push @functions, join(' ', '', map {long2nroff $_} @{ $$q{'alias'} })
158 if defined($$q{'alias'});
159 $r .= join(' ,', @functions);
160 if (defined($$q{'operand'})) {
161 if ($#functions > 0) {
166 $r .= "Ar ".$$q{'operand'};
168 $r .= "\n".$$q{'description'}."\n";
177 my $k = $$h{'short'};
178 $k = $$h{'name'} if !defined($k);
180 if ($l =~ s/^no-//) {
188 my ($x1, $x2) = optionkeyword($a);
189 my ($y1, $y2) = optionkeyword($b);
190 my $r = lc($x1) cmp lc($y1);
197 @operations = sort optioncmp @operations;
198 @operations = sort optioncmp @operations;
199 @options = sort optioncmp @options;
200 @formats = sort optioncmp @formats;
202 if ($#formats >= 0 && !$saw_format) {
203 print STDERR "FIXME: saw --format=X but no root --format!\n";
207 my $function_letters;
208 my $short_letters = join('', sort @short);
211 my $command_string = <<".";
214 $command_string .= ".Oo Fl Oc";
216 my %env_description = (
217 'SIMPLE_BACKUP_SUFFIX' => <<".",
218 Backup prefix to use when extracting, if
221 The backup suffix defaults to `~' if neither is specified.
224 Device or file to use for the archive if
227 If this environment variable is unset, use stdin or stdout instead.
229 'TAR_OPTIONS' => <<".",
230 Options to prepend to those specified on the command line, separated by
231 whitespace. Embedded backslashes may be used to escape whitespace or
232 backslashes within an option.
236 for my $q ( @operations) {
237 $command_string .= " Cm";
238 $command_string .= $sep;
239 $command_string .= " ".$$q{'short'} if defined($$q{'short'});
240 $command_string .= " ".long2nroff($$q{'name'});
241 if (defined($$q{'alias'})) {
242 my $t = join(' ', '', map{long2nroff $_} @{ $$q{'alias'} });
244 $command_string .= $t;
248 $function_letters = ".Bl -tag -width flag\n";
249 $function_letters .= format_options(\@operations);
250 $function_letters .= ".El";
251 if ($#formats >= 0) {
252 $format_letters = ".Bl -tag -width flag\n";
253 $format_letters .= format_options(\@formats);
254 $format_letters .= ".El\n";
255 $$saw_format{'extra'} = $format_letters;
257 ### Ar Cm Ic Li Nm Op Pa Va
258 $option_letters = ".Bl -tag -width flag\n";
259 $option_letters .= format_options(\@options);
260 $option_letters .= ".El";
261 $env_variables .= ".Bl -tag -width Ds\n";
262 for my $q ( @env_vars) {
263 $env_variables .= ".It Ev $q\n";
264 $env_variables .= $env_description{$q};
266 $env_variables .= ".El";
268 $examples =~ s/\n$//;
269 $function_letters =~ s/\n$//;
270 $option_letters =~ s/\n$//;
271 $env_variables =~ s/\n$//;
273 .\\" generated by script on $t
278 .Nd The GNU version of the tar archiving utility
285 stores and extracts files from a tape or disk archive.
287 The first argument to
289 should be a function; either one of the letters
291 or one of the long function names.
292 A function letter need not be prefixed with ``\\-'', and may be combined
293 with other single-letter options.
294 A long function name must be prefixed with
296 Some options take a parameter; with the single-letter form
297 these must be given as separate arguments.
298 With the long form, they may be given by appending
308 The behavior of tar is controlled by the following environment variables,
325 The GNU folks, in general, abhor man pages, and create info documents instead.
326 Unfortunately, the info document describing tar is licensed under the GFDL with
327 invariant cover texts, which makes it impossible to include any text
328 from that document in this man page.
329 Most of the text in this document was automatically extracted from the usage
331 It may not completely describe all features of the program.