No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

239 líneas
11KB

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