You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 satır
8.6KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-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 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Conditional Init Constructs (Debugging with GDB)</title>
  17. <meta name="description" content="Conditional Init Constructs (Debugging with GDB)">
  18. <meta name="keywords" content="Conditional Init Constructs (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Readline-Init-File.html#Readline-Init-File" rel="up" title="Readline Init File">
  26. <link href="Sample-Init-File.html#Sample-Init-File" rel="next" title="Sample Init File">
  27. <link href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax" rel="prev" title="Readline Init File Syntax">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Conditional-Init-Constructs"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Sample-Init-File.html#Sample-Init-File" accesskey="n" rel="next">Sample Init File</a>, Previous: <a href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax" accesskey="p" rel="prev">Readline Init File Syntax</a>, Up: <a href="Readline-Init-File.html#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Conditional-Init-Constructs-1"></a>
  64. <h4 class="subsection">32.3.2 Conditional Init Constructs</h4>
  65. <p>Readline implements a facility similar in spirit to the conditional
  66. compilation features of the C preprocessor which allows key
  67. bindings and variable settings to be performed as the result
  68. of tests. There are four parser directives used.
  69. </p>
  70. <dl compact="compact">
  71. <dt><code>$if</code></dt>
  72. <dd><p>The <code>$if</code> construct allows bindings to be made based on the
  73. editing mode, the terminal being used, or the application using
  74. Readline. The text of the test, after any comparison operator,
  75. extends to the end of the line;
  76. unless otherwise noted, no characters are required to isolate it.
  77. </p>
  78. <dl compact="compact">
  79. <dt><code>mode</code></dt>
  80. <dd><p>The <code>mode=</code> form of the <code>$if</code> directive is used to test
  81. whether Readline is in <code>emacs</code> or <code>vi</code> mode.
  82. This may be used in conjunction
  83. with the &lsquo;<samp>set keymap</samp>&rsquo; command, for instance, to set bindings in
  84. the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if
  85. Readline is starting out in <code>emacs</code> mode.
  86. </p>
  87. </dd>
  88. <dt><code>term</code></dt>
  89. <dd><p>The <code>term=</code> form may be used to include terminal-specific
  90. key bindings, perhaps to bind the key sequences output by the
  91. terminal&rsquo;s function keys. The word on the right side of the
  92. &lsquo;<samp>=</samp>&rsquo; is tested against both the full name of the terminal and
  93. the portion of the terminal name before the first &lsquo;<samp>-</samp>&rsquo;. This
  94. allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>,
  95. for instance.
  96. </p>
  97. </dd>
  98. <dt><code>version</code></dt>
  99. <dd><p>The <code>version</code> test may be used to perform comparisons against
  100. specific Readline versions.
  101. The <code>version</code> expands to the current Readline version.
  102. The set of comparison operators includes
  103. &lsquo;<samp>=</samp>&rsquo; (and &lsquo;<samp>==</samp>&rsquo;), &lsquo;<samp>!=</samp>&rsquo;, &lsquo;<samp>&lt;=</samp>&rsquo;, &lsquo;<samp>&gt;=</samp>&rsquo;, &lsquo;<samp>&lt;</samp>&rsquo;,
  104. and &lsquo;<samp>&gt;</samp>&rsquo;.
  105. The version number supplied on the right side of the operator consists
  106. of a major version number, an optional decimal point, and an optional
  107. minor version (e.g., &lsquo;<samp>7.1</samp>&rsquo;). If the minor version is omitted, it
  108. is assumed to be &lsquo;<samp>0</samp>&rsquo;.
  109. The operator may be separated from the string <code>version</code> and
  110. from the version number argument by whitespace.
  111. The following example sets a variable if the Readline version being used
  112. is 7.0 or newer:
  113. </p><div class="example">
  114. <pre class="example">$if version &gt;= 7.0
  115. set show-mode-in-prompt on
  116. $endif
  117. </pre></div>
  118. </dd>
  119. <dt><code>application</code></dt>
  120. <dd><p>The <var>application</var> construct is used to include
  121. application-specific settings. Each program using the Readline
  122. library sets the <var>application name</var>, and you can test for
  123. a particular value.
  124. This could be used to bind key sequences to functions useful for
  125. a specific program. For instance, the following command adds a
  126. key sequence that quotes the current or previous word in Bash:
  127. </p><div class="example">
  128. <pre class="example">$if Bash
  129. # Quote the current or previous word
  130. &quot;\C-xq&quot;: &quot;\eb\&quot;\ef\&quot;&quot;
  131. $endif
  132. </pre></div>
  133. </dd>
  134. <dt><code>variable</code></dt>
  135. <dd><p>The <var>variable</var> construct provides simple equality tests for Readline
  136. variables and values.
  137. The permitted comparison operators are &lsquo;<samp>=</samp>&rsquo;, &lsquo;<samp>==</samp>&rsquo;, and &lsquo;<samp>!=</samp>&rsquo;.
  138. The variable name must be separated from the comparison operator by
  139. whitespace; the operator may be separated from the value on the right hand
  140. side by whitespace.
  141. Both string and boolean variables may be tested. Boolean variables must be
  142. tested against the values <var>on</var> and <var>off</var>.
  143. The following example is equivalent to the <code>mode=emacs</code> test described
  144. above:
  145. </p><div class="example">
  146. <pre class="example">$if editing-mode == emacs
  147. set show-mode-in-prompt on
  148. $endif
  149. </pre></div>
  150. </dd>
  151. </dl>
  152. </dd>
  153. <dt><code>$endif</code></dt>
  154. <dd><p>This command, as seen in the previous example, terminates an
  155. <code>$if</code> command.
  156. </p>
  157. </dd>
  158. <dt><code>$else</code></dt>
  159. <dd><p>Commands in this branch of the <code>$if</code> directive are executed if
  160. the test fails.
  161. </p>
  162. </dd>
  163. <dt><code>$include</code></dt>
  164. <dd><p>This directive takes a single filename as an argument and reads commands
  165. and bindings from that file.
  166. For example, the following directive reads from <samp>/etc/inputrc</samp>:
  167. </p><div class="example">
  168. <pre class="example">$include /etc/inputrc
  169. </pre></div>
  170. </dd>
  171. </dl>
  172. <hr>
  173. <div class="header">
  174. <p>
  175. Next: <a href="Sample-Init-File.html#Sample-Init-File" accesskey="n" rel="next">Sample Init File</a>, Previous: <a href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax" accesskey="p" rel="prev">Readline Init File Syntax</a>, Up: <a href="Readline-Init-File.html#Readline-Init-File" accesskey="u" rel="up">Readline Init File</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  176. </div>
  177. </body>
  178. </html>