Previous: ar cmdline, Up: ar
ar -M [ <script ]
If you use the single command-line option ‘-M’ with ar, you can control its operation with a rudimentary command language. This form of ar operates interactively if standard input is coming directly from a terminal. During interactive use, ar prompts for input (the prompt is ‘AR >’), and continues executing even after errors. If you redirect standard input to a script file, no prompts are issued, and ar abandons execution (with a nonzero exit code) on any error.
The ar command language is not designed to be equivalent to the command-line options; in fact, it provides somewhat less control over archives. The only purpose of the command language is to ease the transition to gnu ar for developers who already have scripts written for the MRI “librarian” program.
The syntax for the ar command language is straightforward:
LIST
is the same as list
. In the following descriptions, commands are
shown in upper case for clarity.
Here are the commands you can use in ar scripts, or when using ar interactively. Three of them have special significance:
OPEN
or CREATE
specify a current archive, which is
a temporary file required for most of the other commands.
SAVE
commits the changes so far specified by the script. Prior
to SAVE
, commands affect only the temporary copy of the current
archive.
ADDLIB
archiveADDLIB
archive (
module,
module, ...
module)
Requires prior use of OPEN
or CREATE
.
ADDMOD
member,
member, ...
memberRequires prior use of OPEN
or CREATE
.
CLEAR
SAVE
. May be executed (with no
effect) even if no current archive is specified.
CREATE
archiveSAVE
.
You can overwrite existing archives; similarly, the contents of any
existing file named archive will not be destroyed until SAVE
.
DELETE
module,
module, ...
moduleRequires prior use of OPEN
or CREATE
.
DIRECTORY
archive (
module, ...
module)
DIRECTORY
archive (
module, ...
module)
outputfileVERBOSE
specifies the form of the output: when verbose
output is off, output is like that of ‘ar -t archive
module...’. When verbose output is on, the listing is like
‘ar -tv archive module...’.
Output normally goes to the standard output stream; however, if you
specify outputfile as a final argument, ar directs the
output to that file.
END
0
exit code to indicate successful
completion. This command does not save the output file; if you have
changed the current archive since the last SAVE
command, those
changes are lost.
EXTRACT
module,
module, ...
moduleRequires prior use of OPEN
or CREATE
.
LIST
VERBOSE
. The effect is like ‘ar
tv archive’. (This single command is a gnu ar
enhancement, rather than present for MRI compatibility.)
Requires prior use of OPEN
or CREATE
.
OPEN
archiveSAVE
.
REPLACE
module,
module, ...
moduleREPLACE
arguments) from files in the current working directory.
To execute this command without errors, both the file, and the module in
the current archive, must exist.
Requires prior use of OPEN
or CREATE
.
VERBOSE
DIRECTORY
.
When the flag is on, DIRECTORY
output matches output from
‘ar -tv ’....
SAVE
CREATE
or OPEN
command.
Requires prior use of OPEN
or CREATE
.