ar -M [ <script ]
If you use the single command-line option -M with ar, youcan control its operation with a rudimentary command language. Thisform of ar operates interactively if standard input is comingdirectly from a terminal. During interactive use, ar prompts forinput (the prompt is AR >), and continues executing even aftererrors. If you redirect standard input to a script file, no prompts areissued, and ar abandons execution (with a nonzero exit code)on any error.
The ar command language is not designed to be equivalentto the command-line options; in fact, it provides somewhat less controlover archives. The only purpose of the command language is to ease thetransition to gnu ar for developers who already have scriptswritten 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 areshown in upper case for clarity.Here are the commands you can use in ar scripts, or when usingar interactively. Three of them have special significance:
OPEN
or CREATE
specify a current archive, which isa temporary file required for most of the other commands.
SAVE
commits the changes so far specified by the script. Priorto SAVE
, commands affect only the temporary copy of the currentarchive.
ADDLIB
archive
ADDLIB
archive
(
module
,
module
, ...
module
)
Requires prior use of OPEN
or CREATE
.
ADDMOD
member
,
member
, ...
member
Requires prior use of OPEN
or CREATE
.
CLEAR
SAVE
. May be executed (with noeffect) even if no current archive is specified.CREATE
archive
SAVE
. You can overwrite existing archives; similarly, the contents of anyexisting file named archive will not be destroyed until SAVE
.DELETE
module
,
module
, ...
module
Requires prior use of OPEN
or CREATE
.
DIRECTORY
archive
(
module
, ...
module
)
DIRECTORY
archive
(
module
, ...
module
)
outputfile
VERBOSE
specifies the form of the output: when verboseoutput is off, output is like that of ar -t
archive
module
.... When verbose output is on, the listing is likear -tv
archive
module
....Output normally goes to the standard output stream; however, if youspecify outputfile as a final argument, ar directs theoutput to that file.
END
0
exit code to indicate successfulcompletion. This command does not save the output file; if you havechanged the current archive since the last SAVE
command, thosechanges are lost.EXTRACT
module
,
module
, ...
module
Requires prior use of OPEN
or CREATE
.
LIST
VERBOSE
. The effect is like artv
archive. (This single command is a gnu
arenhancement, rather than present for MRI compatibility.)Requires prior use of OPEN
or CREATE
.
OPEN
archive
SAVE
.REPLACE
module
,
module
, ...
module
REPLACE
arguments) from files in the current working directory. To execute this command without errors, both the file, and the module inthe current archive, must exist.Requires prior use of OPEN
or CREATE
.
VERBOSE
DIRECTORY
. When the flag is on, DIRECTORY
output matches output fromar -tv
....SAVE
CREATE
or OPEN
command.Requires prior use of OPEN
or CREATE
.
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.