1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
.\" $OpenBSD: ar.1,v 1.11 2002/12/11 22:01:13 millert Exp $
.\" $NetBSD: ar.1,v 1.7 1995/08/18 15:05:11 pk Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Hugh Smith at The University of Guelph.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)ar.1 8.1 (Berkeley) 6/29/93
.\"
.Dd June 29, 1993
.Dt AR 1
.Os
.Sh NAME
.Nm ar
.Nd create and maintain library archives
.Sh SYNOPSIS
.Nm ar
.Fl d
.Op Fl \Tv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl m
.Op Fl \Tv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl m
.Op Fl abiTv
.Ar position archive
.Or Ar file ...
.Nm ar
.Fl p
.Op Fl \Tv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl q
.Op Fl cTv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl r
.Op Fl cuTv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl r
.Op Fl abciuTv
.Ar position archive
.Op Ar file ...
.Nm ar
.Fl t
.Op Fl \Tv
.Ar archive
.Op Ar file ...
.Nm ar
.Fl x
.Op Fl CouTv
.Ar archive
.Op Ar file ...
.Sh DESCRIPTION
The
.Nm
utility creates and maintains groups of files combined into an archive.
Once an archive has been created, new files can be added and existing
files can be extracted, deleted, or replaced.
.Pp
Files are named in the archive by a single component; i.e., if a file
referenced by a path containing a slash
.Pq Ql /
is archived it will be
named by the last component of that path.
When matching paths listed on the command line against file names stored
in the archive, only the last component of the path will be compared.
.Pp
All informational and error messages use the path listed on the command
line, if any was specified, otherwise the name in the archive is used.
If multiple files in the archive have the same name, and paths are listed
on the command line to
.Dq select
archive files for an operation, only the
.Em first
file with a matching name will be selected.
.Pp
The normal use of
.Nm
is for the creation and maintenance of libraries suitable for use with
the loader (see
.Xr ld 1 )
although it is not restricted to this purpose.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a
A positioning modifier used with the options
.Fl r
and
.Fl m .
The files are entered or moved
.Em after
the archive member
.Ar position ,
which must be specified.
.It Fl b
A positioning modifier used with the options
.Fl r
and
.Fl m .
The files are entered or moved
.Em before
the archive member
.Ar position ,
which must be specified.
.It Fl c
Whenever an archive is created, an informational message to that effect
is written to standard error.
If the
.Fl c
option is specified,
.Nm
creates the archive silently.
.It Fl C
Prevent extracted files from replacing like-named files in the file system.
.It Fl d
Delete the specified archive files.
.It Fl i
Identical to the
.Fl b
option.
.It Fl m
Move the specified archive files within the archive.
If one of the options
.Fl a ,
.Fl b ,
or
.Fl i
are specified, the files are moved before or after the
.Ar position
file in the archive.
If none of those options are specified, the files are moved
to the end of the archive.
.It Fl o
Set the access and modification times of extracted files to the
modification time of the file when it was entered into the archive.
This will fail if the user is not the owner of the extracted file
or the superuser.
.It Fl p
Write the contents of the specified archive files to the standard output.
If no files are specified, the contents of all the files in the archive
are written in the order they appear in the archive.
.It Fl q
(Quickly) append the specified files to the archive.
If the archive does not exist a new archive file is created.
Much faster than the
.Fl r
option, when creating a large archive
piece-by-piece, as no checking is done to see if the files already
exist in the archive.
.It Fl r
Replace or add the specified files to the archive.
If the archive does not exist a new archive file is created.
Files that replace existing files do not change the order of the files
within the archive.
New files are appended to the archive unless one of the options
.Fl a ,
.Fl b ,
or
.Fl i
is specified.
.It Fl T
Select and/or name archive members using only the first fifteen characters
of the archive member or command line file name.
The historic archive format had sixteen bytes for the name, but some
historic archiver and loader implementations were unable to handle names
that used the entire space.
This means that file names that are not unique in their first fifteen
characters can subsequently be confused.
A warning message is printed to the standard error if any file
names are truncated.
(See
.Xr ar 5
for more information.)
.It Fl t
List the specified files in the order in which they appear in the archive,
each on a separate line.
If no files are specified, all files in the archive are listed.
.It Fl u
Update files.
When used with the
.Fl r
option, files in the archive will be replaced
only if the disk file has a newer modification time than the file in
the archive.
When used with the
.Fl x
option, files in the archive will be extracted
only if the archive file has a newer modification time than the file
on disk.
.It Fl v
Provide verbose output.
When used with the
.Fl d ,
.Fl m ,
.Fl q ,
or
.Fl x
options,
.Nm
gives a file-by-file description of the archive modification.
This description consists of three, whitespace-separated fields: the
option letter, a dash
.Pq Ql - ,
and the file name.
When used with the
.Fl r
option,
.Nm
displays the description as above, but the initial letter is an
.Sq a
if
the file is added to the archive and an
.Sq r
if the file replaces a file
already in the archive.
.Pp
When used with the
.Fl p
option,
the name of each printed file is written to the standard output before
the contents of the file, preceded by a single newline character, and
followed by two newline characters, enclosed in less-than
.Pq Ql <
and
greater-than
.Pq Ql >
characters.
.Pp
When used with the
.Fl t
option,
.Nm
displays an
.Dq ls -l
style listing of information about the members of
the archive.
This listing consists of eight, whitespace-separated fields:
the file permissions (see
.Xr strmode 3 ) ,
the decimal user and group IDs, separated by a single slash
.Pq Ql / ,
the file size (in bytes), the file modification time (in the
.Xr date 1
format
.Dq %b %e %H:%M %Y ) ,
and the name of the file.
.It Fl x
Extract the specified archive members into the files named by the command
line arguments.
If no members are specified, all the members of the archive are extracted into
the current directory.
.Pp
If the file does not exist, it is created; if it does exist, the owner
and group will be unchanged.
The file access and modification times are the time of the extraction
(but see the
.Fl o
option).
The file permissions will be set to those of the file when it was entered
into the archive; this will fail if the user is not the owner of the
extracted file or the superuser.
.El
.Pp
The
.Nm
utility exits 0 on success or >0 if an error occurred.
.Sh ENVIRONMENT
.Bl -tag -width indent -compact
.It Ev TMPDIR
The pathname of the directory to use when creating temporary files.
.El
.Sh FILES
.Bl -tag -width ar.XXXXXXXXXX -compact
.It Pa /tmp
default temporary file directory
.It Pa ar.XXXXXXXXXX
temporary file names
.El
.Sh SEE ALSO
.Xr ld 1 ,
.Xr ranlib 1 ,
.Xr strmode 3 ,
.Xr ar 5
.Sh COMPATIBILITY
By default,
.Nm
writes archives that may be incompatible with historic archives, as
the format used for storing archive members with names longer than
fifteen characters has changed.
This implementation of
.Nm
is backward compatible with previous versions of
.Nm
in that it can read and write (using the
.Fl T
option) historic archives.
The
.Fl T
option is provided for compatibility only, and will be deleted
in a future release.
See
.Xr ar 5
for more information.
.Sh STANDARDS
The
.Nm
utility is expected to offer a superset of the
.St -p1003.2
functionality.
|