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