1<html lang="en"> 2<head> 3<title>ar scripts - GNU Binary Utilities</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="GNU Binary Utilities"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="ar.html#ar" title="ar"> 9<link rel="prev" href="ar-cmdline.html#ar-cmdline" title="ar cmdline"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1991-2013 Free Software Foundation, Inc. 13 14Permission is granted to copy, distribute and/or modify this document 15under the terms of the GNU Free Documentation License, Version 1.3 16or any later version published by the Free Software Foundation; 17with no Invariant Sections, with no Front-Cover Texts, and with no 18Back-Cover Texts. A copy of the license is included in the 19section entitled ``GNU Free Documentation License''. 20 21--> 22<meta http-equiv="Content-Style-Type" content="text/css"> 23<style type="text/css"><!-- 24 pre.display { font-family:inherit } 25 pre.format { font-family:inherit } 26 pre.smalldisplay { font-family:inherit; font-size:smaller } 27 pre.smallformat { font-family:inherit; font-size:smaller } 28 pre.smallexample { font-size:smaller } 29 pre.smalllisp { font-size:smaller } 30 span.sc { font-variant:small-caps } 31 span.roman { font-family:serif; font-weight:normal; } 32 span.sansserif { font-family:sans-serif; font-weight:normal; } 33--></style> 34<link rel="stylesheet" type="text/css" href="../cs.css"> 35</head> 36<body> 37<div class="node"> 38<a name="ar-scripts"></a> 39<p> 40Previous: <a rel="previous" accesskey="p" href="ar-cmdline.html#ar-cmdline">ar cmdline</a>, 41Up: <a rel="up" accesskey="u" href="ar.html#ar">ar</a> 42<hr> 43</div> 44 45<h3 class="section">1.2 Controlling <samp><span class="command">ar</span></samp> with a Script</h3> 46 47<pre class="smallexample"> ar -M [ <<var>script</var> ] 48</pre> 49 <p><a name="index-MRI-compatibility_002c-_0040command_007bar_007d-34"></a><a name="index-scripts_002c-_0040command_007bar_007d-35"></a>If you use the single command-line option ‘<samp><span class="samp">-M</span></samp>’ with <samp><span class="command">ar</span></samp>, you 50can control its operation with a rudimentary command language. This 51form of <samp><span class="command">ar</span></samp> operates interactively if standard input is coming 52directly from a terminal. During interactive use, <samp><span class="command">ar</span></samp> prompts for 53input (the prompt is ‘<samp><span class="samp">AR ></span></samp>’), and continues executing even after 54errors. If you redirect standard input to a script file, no prompts are 55issued, and <samp><span class="command">ar</span></samp> abandons execution (with a nonzero exit code) 56on any error. 57 58 <p>The <samp><span class="command">ar</span></samp> command language is <em>not</em> designed to be equivalent 59to the command-line options; in fact, it provides somewhat less control 60over archives. The only purpose of the command language is to ease the 61transition to <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> for developers who already have scripts 62written for the MRI “librarian” program. 63 64 <p>The syntax for the <samp><span class="command">ar</span></samp> command language is straightforward: 65 <ul> 66<li>commands are recognized in upper or lower case; for example, <code>LIST</code> 67is the same as <code>list</code>. In the following descriptions, commands are 68shown in upper case for clarity. 69 70 <li>a single command may appear on each line; it is the first word on the 71line. 72 73 <li>empty lines are allowed, and have no effect. 74 75 <li>comments are allowed; text after either of the characters ‘<samp><span class="samp">*</span></samp>’ 76or ‘<samp><span class="samp">;</span></samp>’ is ignored. 77 78 <li>Whenever you use a list of names as part of the argument to an <samp><span class="command">ar</span></samp> 79command, you can separate the individual names with either commas or 80blanks. Commas are shown in the explanations below, for clarity. 81 82 <li>‘<samp><span class="samp">+</span></samp>’ is used as a line continuation character; if ‘<samp><span class="samp">+</span></samp>’ appears 83at the end of a line, the text on the following line is considered part 84of the current command. 85</ul> 86 87 <p>Here are the commands you can use in <samp><span class="command">ar</span></samp> scripts, or when using 88<samp><span class="command">ar</span></samp> interactively. Three of them have special significance: 89 90 <p><code>OPEN</code> or <code>CREATE</code> specify a <dfn>current archive</dfn>, which is 91a temporary file required for most of the other commands. 92 93 <p><code>SAVE</code> commits the changes so far specified by the script. Prior 94to <code>SAVE</code>, commands affect only the temporary copy of the current 95archive. 96 97 <dl> 98<dt><code>ADDLIB </code><var>archive</var><dt><code>ADDLIB </code><var>archive</var><code> (</code><var>module</var><code>, </code><var>module</var><code>, ... </code><var>module</var><code>)</code><dd>Add all the contents of <var>archive</var> (or, if specified, each named 99<var>module</var> from <var>archive</var>) to the current archive. 100 101 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 102 103 <br><dt><code>ADDMOD </code><var>member</var><code>, </code><var>member</var><code>, ... </code><var>member</var><dd><!-- FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" --> 104<!-- else like "ar q..." --> 105Add each named <var>member</var> as a module in the current archive. 106 107 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 108 109 <br><dt><code>CLEAR</code><dd>Discard the contents of the current archive, canceling the effect of 110any operations since the last <code>SAVE</code>. May be executed (with no 111effect) even if no current archive is specified. 112 113 <br><dt><code>CREATE </code><var>archive</var><dd>Creates an archive, and makes it the current archive (required for many 114other commands). The new archive is created with a temporary name; it 115is not actually saved as <var>archive</var> until you use <code>SAVE</code>. 116You can overwrite existing archives; similarly, the contents of any 117existing file named <var>archive</var> will not be destroyed until <code>SAVE</code>. 118 119 <br><dt><code>DELETE </code><var>module</var><code>, </code><var>module</var><code>, ... </code><var>module</var><dd>Delete each listed <var>module</var> from the current archive; equivalent to 120‘<samp><span class="samp">ar -d </span><var>archive</var> <var>module</var><span class="samp"> ... </span><var>module</var></samp>’. 121 122 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 123 124 <br><dt><code>DIRECTORY </code><var>archive</var><code> (</code><var>module</var><code>, ... </code><var>module</var><code>)</code><dt><code>DIRECTORY </code><var>archive</var><code> (</code><var>module</var><code>, ... </code><var>module</var><code>) </code><var>outputfile</var><dd>List each named <var>module</var> present in <var>archive</var>. The separate 125command <code>VERBOSE</code> specifies the form of the output: when verbose 126output is off, output is like that of ‘<samp><span class="samp">ar -t </span><var>archive</var> 127<var>module</var><span class="samp">...</span></samp>’. When verbose output is on, the listing is like 128‘<samp><span class="samp">ar -tv </span><var>archive</var> <var>module</var><span class="samp">...</span></samp>’. 129 130 <p>Output normally goes to the standard output stream; however, if you 131specify <var>outputfile</var> as a final argument, <samp><span class="command">ar</span></samp> directs the 132output to that file. 133 134 <br><dt><code>END</code><dd>Exit from <samp><span class="command">ar</span></samp>, with a <code>0</code> exit code to indicate successful 135completion. This command does not save the output file; if you have 136changed the current archive since the last <code>SAVE</code> command, those 137changes are lost. 138 139 <br><dt><code>EXTRACT </code><var>module</var><code>, </code><var>module</var><code>, ... </code><var>module</var><dd>Extract each named <var>module</var> from the current archive, writing them 140into the current directory as separate files. Equivalent to ‘<samp><span class="samp">ar -x 141</span><var>archive</var> <var>module</var><span class="samp">...</span></samp>’. 142 143 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 144 145 <br><dt><code>LIST</code><dd>Display full contents of the current archive, in “verbose” style 146regardless of the state of <code>VERBOSE</code>. The effect is like ‘<samp><span class="samp">ar 147tv </span><var>archive</var></samp>’. (This single command is a <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> 148enhancement, rather than present for MRI compatibility.) 149 150 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 151 152 <br><dt><code>OPEN </code><var>archive</var><dd>Opens an existing archive for use as the current archive (required for 153many other commands). Any changes as the result of subsequent commands 154will not actually affect <var>archive</var> until you next use <code>SAVE</code>. 155 156 <br><dt><code>REPLACE </code><var>module</var><code>, </code><var>module</var><code>, ... </code><var>module</var><dd>In the current archive, replace each existing <var>module</var> (named in 157the <code>REPLACE</code> arguments) from files in the current working directory. 158To execute this command without errors, both the file, and the module in 159the current archive, must exist. 160 161 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 162 163 <br><dt><code>VERBOSE</code><dd>Toggle an internal flag governing the output from <code>DIRECTORY</code>. 164When the flag is on, <code>DIRECTORY</code> output matches output from 165‘<samp><span class="samp">ar -tv </span></samp>’<small class="dots">...</small>. 166 167 <br><dt><code>SAVE</code><dd>Commit your changes to the current archive, and actually save it as a 168file with the name specified in the last <code>CREATE</code> or <code>OPEN</code> 169command. 170 171 <p>Requires prior use of <code>OPEN</code> or <code>CREATE</code>. 172 173 </dl> 174 175 </body></html> 176 177