]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man1p/ar.1p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man1p / ar.1p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "AR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" ar
4 .SH NAME
5 ar \- create and maintain library archives
6 .SH SYNOPSIS
7 .LP
8 \fBar -d\fP\fB[\fP\fB-v\fP\fB]\fP \fIarchive file\fP \fB... \fP
9 \fB
10 .br
11 .sp
12 \fP
13 .LP
14 \fBar -m\fP \fB[\fP\fB-v\fP\fB]\fP \fIarchive file\fP \fB...
15 .br
16 .sp
17 ar -m -a\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB...
18 .br
19 .sp
20 ar -m -b\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB...
21 .br
22 .sp
23 ar -m -i\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB...
24 \fP
25 \fB
26 .br
27 .sp
28 ar -p\fP\fB[\fP\fB-v\fP\fB][\fP\fB-s\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP
29 \fB\&...\fP\fB]\fP\fB
30 .br
31 .sp
32 \fP
33 .LP
34 \fBar -q\fP\fB[\fP\fB-cv\fP\fB]\fP \fIarchive file\fP \fB... \fP
35 \fB
36 .br
37 .sp
38 ar -r\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIarchive file\fP \fB...
39 .br
40 .sp
41 \fP
42 .LP
43 \fBar -r -a\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP
44 \fB\&...
45 .br
46 .sp
47 ar -r -b\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP \fB...
48 .br
49 .sp
50 ar -r -i\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP \fB...
51 \fP
52 \fB
53 .br
54 .sp
55 ar -t\fP\fB[\fP\fB-v\fP\fB][\fP\fB-s\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP
56 \fB\&...\fP\fB]\fP\fB
57 .br
58 .sp
59 ar -x\fP\fB[\fP\fB-v\fP\fB][\fP\fB-sCT\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP
60 \fB\&...\fP\fB]\fP\fB
61 .br
62 \fP
63 .SH DESCRIPTION
64 .LP
65 The \fIar\fP utility is part of the Software Development Utilities
66 option.
67 .LP
68 The \fIar\fP utility can be used to create and maintain groups of
69 files combined into an archive. Once an archive has been
70 created, new files can be added, and existing files in an archive
71 can be extracted, deleted, or replaced. When an archive consists
72 entirely of valid object files, the implementation shall format the
73 archive so that it is usable as a library for link editing (see
74 \fIc99\fP and \fIfort77\fP). When some of the archived
75 files are not valid object files, the suitability of the archive for
76 library use is undefined. \ If an
77 archive consists entirely of printable files, the entire archive shall
78 be printable.
79 .LP
80 When \fIar\fP creates an archive, it creates administrative information
81 indicating whether a symbol table is present in the
82 archive. When there is at least one object file that \fIar\fP recognizes
83 as such in the archive, an archive symbol table shall be
84 created in the archive and maintained by \fIar\fP; it is used by the
85 link editor to search the archive. Whenever the \fIar\fP
86 utility is used to create or update the contents of such an archive,
87 the symbol table shall be rebuilt. The \fB-s\fP option shall
88 force the symbol table to be rebuilt.
89 .LP
90 All \fIfile\fP operands can be pathnames. However, files within archives
91 shall be named by a filename, which is the last
92 component of the pathname used when the file was entered into the
93 archive. The comparison of \fIfile\fP operands to the names of
94 files in archives shall be performed by comparing the last component
95 of the operand to the name of the file in the archive.
96 .LP
97 It is unspecified whether multiple files in the archive may be identically
98 named. In the case of such files, however, each
99 \fIfile\fP \ and \fIposname\fP operand shall match only the
100 first file in the archive having a name that is the same as the last
101 component of the operand.
102 .SH OPTIONS
103 .LP
104 The \fIar\fP utility shall conform to the Base Definitions volume
105 of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
106 .LP
107 The following options shall be supported:
108 .TP 7
109 \fB-a\fP
110 Position new files in the archive after the file named by the \fIposname\fP
111 operand.
112 .TP 7
113 \fB-b\fP
114 Position new files in the archive before the file named by the \fIposname\fP
115 operand.
116 .TP 7
117 \fB-c\fP
118 Suppress the diagnostic message that is written to standard error
119 by default when the archive \fIarchive\fP is created.
120 .TP 7
121 \fB-C\fP
122 Prevent extracted files from replacing like-named files in the file
123 system. This option is useful when \fB-T\fP is also used, to
124 prevent truncated filenames from replacing files with the same prefix.
125 .TP 7
126 \fB-d\fP
127 Delete one or more \fIfile\fPs from \fIarchive\fP.
128 .TP 7
129 \fB-i\fP
130 Position new files in the archive before the file in the archive named
131 by the \fIposname\fP operand (equivalent to \fB-b\fP).
132 .TP 7
133 \fB-m\fP
134 Move the named files in the archive. The \fB-a\fP, \fB-b\fP, or \fB-i\fP
135 options with the \fIposname\fP operand indicate the
136 position; otherwise, move the names files in the archive to the end
137 of the archive.
138 .TP 7
139 \fB-p\fP
140 Write the contents of the \fIfile\fPs in the archive named by \fIfile\fP
141 operands from \fIarchive\fP to the standard output.
142 If no \fIfile\fP operands are specified, the contents of all files
143 in the archive shall be written in the order of the
144 archive.
145 .TP 7
146 \fB-q\fP
147 Append the named files to the end of the archive. In this case \fIar\fP
148 does not check whether the added files are already in the
149 archive. This is useful to bypass the searching otherwise done when
150 creating a large archive piece by piece.
151 .TP 7
152 \fB-r\fP
153 Replace or add \fIfile\fPs to \fIarchive\fP. If the archive named
154 by \fIarchive\fP does not exist, a new archive shall be
155 created and a diagnostic message shall be written to standard error
156 (unless the \fB-c\fP option is specified). If no \fIfile\fPs
157 are specified and the \fIarchive\fP exists, the results are undefined.
158 Files that replace existing files in the archive shall not
159 change the order of the archive. Files that do not replace existing
160 files in the archive shall be appended to the archive \ unless
161 a \fB-a\fP, \fB-b\fP, or \fB-i\fP option specifies another position.
162 .TP 7
163 \fB-s\fP
164 Force the regeneration of the archive symbol table even if \fIar\fP
165 is not invoked with an option that modifies the archive
166 contents. This option is useful to restore the archive symbol table
167 after it has been stripped; see \fIstrip\fP.
168 .TP 7
169 \fB-t\fP
170 Write a table of contents of \fIarchive\fP to the standard output.
171 The files specified by the \fIfile\fP operands shall be
172 included in the written list. If no \fIfile\fP operands are specified,
173 all files in \fIarchive\fP shall be included in the order
174 of the archive.
175 .TP 7
176 \fB-T\fP
177 Allow filename truncation of extracted files whose archive names are
178 longer than the file system can support. By default,
179 extracting a file with a name that is too long shall be an error;
180 a diagnostic message shall be written and the file shall not be
181 extracted.
182 .TP 7
183 \fB-u\fP
184 Update older files in the archive. When used with the \fB-r\fP option,
185 files in the archive shall be replaced only if the
186 corresponding \fIfile\fP has a modification time that is at least
187 as new as the modification time of the file in the archive.
188 .TP 7
189 \fB-v\fP
190 Give verbose output. When used with the option characters \fB-d\fP,
191 \fB-r\fP, or \fB-x\fP, write a detailed file-by-file
192 description of the archive creation and maintenance activity, as described
193 in the STDOUT section.
194 .LP
195 When used with \fB-p\fP, write the name of the file in the archive
196 to the standard output before writing the file in the
197 archive itself to the standard output, as described in the STDOUT
198 section.
199 .LP
200 When used with \fB-t\fP, include a long listing of information about
201 the files in the archive, as described in the STDOUT
202 section.
203 .TP 7
204 \fB-x\fP
205 Extract the files in the archive named by the \fIfile\fP operands
206 from \fIarchive\fP. The contents of the archive shall not
207 be changed. If no \fIfile\fP operands are given, all files in the
208 archive shall be extracted. The modification time of each file
209 extracted shall be set to the time the file is extracted from the
210 archive.
211 .sp
212 .SH OPERANDS
213 .LP
214 The following operands shall be supported:
215 .TP 7
216 \fIarchive\fP
217 A pathname of the archive.
218 .TP 7
219 \fIfile\fP
220 A pathname. Only the last component shall be used when comparing against
221 the names of files in the archive. If two or more
222 \fIfile\fP operands have the same last pathname component (basename),
223 the results are unspecified. The implementation's archive
224 format shall not truncate valid filenames of files added to or replaced
225 in the archive.
226 .TP 7
227 \fIposname\fP
228 The name of a file in the archive, used for relative positioning;
229 see options \fB-m\fP and \fB-r\fP.
230 .sp
231 .SH STDIN
232 .LP
233 Not used.
234 .SH INPUT FILES
235 .LP
236 The archive named by \fIarchive\fP shall be a file in the format created
237 by \fIar\fP \fB-r\fP.
238 .SH ENVIRONMENT VARIABLES
239 .LP
240 The following environment variables shall affect the execution of
241 \fIar\fP:
242 .TP 7
243 \fILANG\fP
244 Provide a default value for the internationalization variables that
245 are unset or null. (See the Base Definitions volume of
246 IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables
247 for
248 the precedence of internationalization variables used to determine
249 the values of locale categories.)
250 .TP 7
251 \fILC_ALL\fP
252 If set to a non-empty string value, override the values of all the
253 other internationalization variables.
254 .TP 7
255 \fILC_CTYPE\fP
256 Determine the locale for the interpretation of sequences of bytes
257 of text data as characters (for example, single-byte as
258 opposed to multi-byte characters in arguments and input files).
259 .TP 7
260 \fILC_MESSAGES\fP
261 Determine the locale that should be used to affect the format and
262 contents of diagnostic messages written to standard
263 error.
264 .TP 7
265 \fILC_TIME\fP
266 Determine the format and content for date and time strings written
267 by \fIar\fP \fB-tv\fP.
268 .TP 7
269 \fINLSPATH\fP
270 Determine the location of message catalogs for the processing of \fILC_MESSAGES
271 \&.\fP
272 .TP 7
273 \fITMPDIR\fP
274 Determine the pathname that overrides the default directory for temporary
275 files, if any.
276 .TP 7
277 \fITZ\fP
278 Determine the timezone used to calculate date and time strings written
279 by \fIar\fP \fB-tv\fP. If \fITZ\fP is unset or null,
280 an unspecified default timezone shall be used.
281 .sp
282 .SH ASYNCHRONOUS EVENTS
283 .LP
284 Default.
285 .SH STDOUT
286 .LP
287 If the \fB-d\fP option is used with the \fB-v\fP option, the standard
288 output format shall be:
289 .sp
290 .RS
291 .nf
292
293 \fB"d - %s\\n", <\fP\fIfile\fP\fB>
294 \fP
295 .fi
296 .RE
297 .LP
298 where \fIfile\fP is the operand specified on the command line.
299 .LP
300 If the \fB-p\fP option is used with the \fB-v\fP option, \fIar\fP
301 shall precede the contents of each file with:
302 .sp
303 .RS
304 .nf
305
306 \fB"\\n<%s>\\n\\n", <\fP\fIfile\fP\fB>
307 \fP
308 .fi
309 .RE
310 .LP
311 where \fIfile\fP is the operand specified on the command line, if
312 \fIfile\fP operands were specified, and the name of the file
313 in the archive if they were not.
314 .LP
315 If the \fB-r\fP option is used with the \fB-v\fP option:
316 .IP " *" 3
317 If \fIfile\fP is already in the archive, the standard output format
318 shall be:
319 .sp
320 .RS
321 .nf
322
323 \fB"r - %s\\n", <\fP\fIfile\fP\fB>
324 \fP
325 .fi
326 .RE
327 .LP
328 where <\fIfile\fP> is the operand specified on the command line.
329 .LP
330 .IP " *" 3
331 If \fIfile\fP is not already in the archive, the standard output format
332 shall be:
333 .sp
334 .RS
335 .nf
336
337 \fB"a - %s\\n", <\fP\fIfile\fP\fB>
338 \fP
339 .fi
340 .RE
341 .LP
342 where <\fIfile\fP> is the operand specified on the command line.
343 .LP
344 .LP
345 If the \fB-t\fP option is used, \fIar\fP shall write the names of
346 the files in the archive to the standard output in the
347 format:
348 .sp
349 .RS
350 .nf
351
352 \fB"%s\\n", <\fP\fIfile\fP\fB>
353 \fP
354 .fi
355 .RE
356 .LP
357 where \fIfile\fP is the operand specified on the command line, if
358 \fIfile\fP operands were specified, or the name of the file
359 in the archive if they were not.
360 .LP
361 If the \fB-t\fP option is used with the \fB-v\fP option, the standard
362 output format shall be:
363 .sp
364 .RS
365 .nf
366
367 \fB"%s %u/%u %u %s %d %d:%d %d %s\\n", <\fP\fImember mode\fP\fB>, <\fP\fIuser ID\fP\fB>,
368 <\fP\fIgroup ID\fP\fB>, <\fP\fInumber of bytes in member\fP\fB>,
369 <\fP\fIabbreviated month\fP\fB>, <\fP\fIday-of-month\fP\fB>, <\fP\fIhour\fP\fB>,
370 <\fP\fIminute\fP\fB>, <\fP\fIyear\fP\fB>, <\fP\fIfile\fP\fB>
371 \fP
372 .fi
373 .RE
374 .LP
375 where:
376 .TP 7
377 <\fIfile\fP>
378 Shall be the operand specified on the command line, if \fIfile\fP
379 operands were specified, or the name of the file in the
380 archive if they were not.
381 .TP 7
382 <\fImember\ mode\fP>
383 .sp
384 Shall be formatted the same as the <\fIfile\ mode\fP> string defined
385 in the STDOUT section of \fIls\fP, except that the first character,
386 the <\fIentry\ type\fP>, is not used; the string
387 represents the file mode of the file in the archive at the time it
388 was added to or replaced in the archive.
389 .sp
390 .LP
391 The following represent the last-modification time of a file when
392 it was most recently added to or replaced in the archive:
393 .TP 7
394 <\fIabbreviated\ month\fP>
395 .sp
396 Equivalent to the format of the \fB%b\fP conversion specification
397 format in \fIdate\fP.
398 .TP 7
399 <\fIday-of-month\fP>
400 .sp
401 Equivalent to the format of the \fB%e\fP conversion specification
402 format in \fIdate\fP.
403 .TP 7
404 <\fIhour\fP>
405 Equivalent to the format of the \fB%H\fP conversion specification
406 format in \fIdate\fP.
407 .TP 7
408 <\fIminute\fP>
409 Equivalent to the format of the \fB%M\fP conversion specification
410 format in \fIdate\fP.
411 .TP 7
412 <\fIyear\fP>
413 Equivalent to the format of the \fB%Y\fP conversion specification
414 format in \fIdate\fP.
415 .sp
416 .LP
417 When \fILC_TIME\fP does not specify the POSIX locale, a different
418 format and order of presentation of these fields relative to
419 each other may be used in a format appropriate in the specified locale.
420 .LP
421 If the \fB-x\fP option is used with the \fB-v\fP option, the standard
422 output format shall be:
423 .sp
424 .RS
425 .nf
426
427 \fB"x - %s\\n", <\fP\fIfile\fP\fB>
428 \fP
429 .fi
430 .RE
431 .LP
432 where \fIfile\fP is the operand specified on the command line, if
433 \fIfile\fP operands were specified, or the name of the file
434 in the archive if they were not.
435 .SH STDERR
436 .LP
437 The standard error shall be used only for diagnostic messages. The
438 diagnostic message about creating a new archive when
439 \fB-c\fP is not specified shall not modify the exit status.
440 .SH OUTPUT FILES
441 .LP
442 Archives are files with unspecified formats.
443 .SH EXTENDED DESCRIPTION
444 .LP
445 None.
446 .SH EXIT STATUS
447 .LP
448 The following exit values shall be returned:
449 .TP 7
450 \ 0
451 Successful completion.
452 .TP 7
453 >0
454 An error occurred.
455 .sp
456 .SH CONSEQUENCES OF ERRORS
457 .LP
458 Default.
459 .LP
460 \fIThe following sections are informative.\fP
461 .SH APPLICATION USAGE
462 .LP
463 None.
464 .SH EXAMPLES
465 .LP
466 None.
467 .SH RATIONALE
468 .LP
469 The archive format is not described. It is recognized that there are
470 several known \fIar\fP formats, which are not compatible.
471 The \fIar\fP utility is included, however, to allow creation of archives
472 that are intended for use only on one machine. The
473 archive is specified as a file, and it can be moved as a file. This
474 does allow an archive to be moved from one machine to another
475 machine that uses the same implementation of \fIar\fP.
476 .LP
477 Utilities such as \fIpax\fP (and its forebears \fItar\fP and \fIcpio\fP)
478 also provide
479 portable "archives". This is a not a duplication; the \fIar\fP utility
480 is included to provide an interface primarily for \fImake\fP and the
481 compilers, based on a historical model.
482 .LP
483 In historical implementations, the \fB-q\fP option (available on XSI-conforming
484 systems) is known to execute quickly because
485 \fIar\fP does not check on whether the added members are already in
486 the archive. This is useful to bypass the searching otherwise
487 done when creating a large archive piece-by-piece. These remarks may
488 but need not remain true for a brand new implementation of
489 this utility; hence, these remarks have been moved into the RATIONALE.
490 .LP
491 BSD implementations historically required applications to provide
492 the \fB-s\fP option whenever the archive was supposed to
493 contain a symbol table. As in this volume of IEEE\ Std\ 1003.1-2001,
494 System V historically creates or updates an archive
495 symbol table whenever an object file is removed from, added to, or
496 updated in the archive.
497 .LP
498 The OPERANDS section requires what might seem to be true without specifying
499 it: the archive cannot truncate the filenames below
500 {NAME_MAX}. Some historical implementations do so, however, causing
501 unexpected results for the application. Therefore, this volume
502 of IEEE\ Std\ 1003.1-2001 makes the requirement explicit to avoid
503 misunderstandings.
504 .LP
505 According to the System V documentation, the options \fB-dmpqrtx\fP
506 are not required to begin with a hyphen ( \fB'-'\fP ).
507 This volume of IEEE\ Std\ 1003.1-2001 requires that a conforming application
508 use the leading hyphen.
509 .LP
510 The archive format used by the 4.4 BSD implementation is documented
511 in this RATIONALE as an example:
512 A file created by \fIar\fP begins with the "magic" string \fB"!<arch>\\n"\fP
513 \&. The rest of the archive is
514 made up of objects, each of which is composed of a header for a file,
515 a possible filename, and the file contents. The header is
516 portable between machine architectures, and, if the file contents
517 are printable, the archive is itself printable.
518 .LP
519 The header is made up of six ASCII fields, followed by a two-character
520 trailer. The fields are the object name (16 characters),
521 the file last modification time (12 characters), the user and group
522 IDs (each 6 characters), the file mode (8 characters), and the
523 file size (10 characters). All numeric fields are in decimal, except
524 for the file mode, which is in octal.
525 .LP
526 The modification time is the file \fIst_mtime\fP field. The user and
527 group IDs are the file \fIst_uid\fP and \fIst_gid\fP
528 fields. The file mode is the file \fIst_mode\fP field. The file size
529 is the file \fIst_size\fP field. The two-byte trailer is the
530 string \fB"`<newline>"\fP .
531 .LP
532 Only the name field has any provision for overflow. If any filename
533 is more than 16 characters in length or contains an embedded
534 space, the string \fB"#1/"\fP followed by the ASCII length of the
535 name is written in the name field. The file size (stored in
536 the archive header) is incremented by the length of the name. The
537 name is then written immediately following the archive
538 header.
539 .LP
540 Any unused characters in any of these fields are written as <space>s.
541 If any fields are their particular maximum number of
542 characters in length, there is no separation between the fields.
543 .LP
544 Objects in the archive are always an even number of bytes long; files
545 that are an odd number of bytes long are padded with a
546 <newline>, although the size in the header does not reflect this.
547 .LP
548 The \fIar\fP utility description requires that (when all its members
549 are valid object files) \fIar\fP produce an object code
550 library, which the linkage editor can use to extract object modules.
551 If the linkage editor needs a symbol table to permit random
552 access to the archive, \fIar\fP must provide it; however, \fIar\fP
553 does not require a symbol table.
554 .LP
555 The BSD \fB-o\fP option was omitted. It is a rare conforming application
556 that uses \fIar\fP to extract object code from a
557 library with concern for its modification time, since this can only
558 be of importance to \fImake\fP. Hence, since this functionality is
559 not deemed important for applications portability, the
560 modification time of the extracted files is set to the current time.
561 .LP
562 There is at least one known implementation (for a small computer)
563 that can accommodate only object files for that system,
564 disallowing mixed object and other files. The ability to handle any
565 type of file is not only historical practice for most
566 implementations, but is also a reasonable expectation.
567 .LP
568 Consideration was given to changing the output format of \fIar\fP
569 \fB-tv\fP to the same format as the output of \fIls\fP \fB-l\fP. This
570 would have made parsing the output of \fIar\fP the same as that of
571 \fIls\fP. This was rejected in part because the current \fIar\fP format
572 is commonly used and changes
573 would break historical usage. Second, \fIar\fP gives the user ID and
574 group ID in numeric format separated by a slash. Changing
575 this to be the user name and group name would not be correct if the
576 archive were moved to a machine that contained a different user
577 database. Since \fIar\fP cannot know whether the archive was generated
578 on the same machine, it cannot tell what to report.
579 .LP
580 The text on the \fB-ur\fP option combination is historical practice-since
581 one filename can easily represent two different files
582 (for example, \fB/a/foo\fP and \fB/b/foo\fP), it is reasonable to
583 replace the file in the archive even when the modification time
584 in the archive is identical to that in the file system.
585 .SH FUTURE DIRECTIONS
586 .LP
587 None.
588 .SH SEE ALSO
589 .LP
590 \fIc99\fP , \fIdate\fP , \fIfort77\fP , \fIpax\fP , \fIstrip\fP the
591 Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 13, Headers,
592 \fI<unistd.h>\fP
593 description of {POSIX_NO_TRUNC}
594 .SH COPYRIGHT
595 Portions of this text are reprinted and reproduced in electronic form
596 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
597 -- Portable Operating System Interface (POSIX), The Open Group Base
598 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
599 Electrical and Electronics Engineers, Inc and The Open Group. In the
600 event of any discrepancy between this version and the original IEEE and
601 The Open Group Standard, the original IEEE and The Open Group Standard
602 is the referee document. The original Standard can be obtained online at
603 http://www.opengroup.org/unix/online.html .