|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
-
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "Free Software" and "Free Software Needs
- Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
- and with the Back-Cover Texts as in (a) below.
-
- (a) The FSF's Back-Cover Text is: "You are free to copy and modify
- this GNU Manual. Buying copies from GNU Press supports the FSF in
- developing GNU and promoting software freedom." -->
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Conditional Init Constructs (Debugging with GDB)</title>
-
- <meta name="description" content="Conditional Init Constructs (Debugging with GDB)">
- <meta name="keywords" content="Conditional Init Constructs (Debugging with GDB)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Readline-Init-File.html#Readline-Init-File" rel="up" title="Readline Init File">
- <link href="Sample-Init-File.html#Sample-Init-File" rel="next" title="Sample Init File">
- <link href="Readline-Init-File-Syntax.html#Readline-Init-File-Syntax" rel="prev" title="Readline Init File Syntax">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="Conditional-Init-Constructs"></a>
- <div class="header">
- <p>
- 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> [<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>
- </div>
- <hr>
- <a name="Conditional-Init-Constructs-1"></a>
- <h4 class="subsection">32.3.2 Conditional Init Constructs</h4>
-
- <p>Readline implements a facility similar in spirit to the conditional
- compilation features of the C preprocessor which allows key
- bindings and variable settings to be performed as the result
- of tests. There are four parser directives used.
- </p>
- <dl compact="compact">
- <dt><code>$if</code></dt>
- <dd><p>The <code>$if</code> construct allows bindings to be made based on the
- editing mode, the terminal being used, or the application using
- Readline. The text of the test, after any comparison operator,
- extends to the end of the line;
- unless otherwise noted, no characters are required to isolate it.
- </p>
- <dl compact="compact">
- <dt><code>mode</code></dt>
- <dd><p>The <code>mode=</code> form of the <code>$if</code> directive is used to test
- whether Readline is in <code>emacs</code> or <code>vi</code> mode.
- This may be used in conjunction
- with the ‘<samp>set keymap</samp>’ command, for instance, to set bindings in
- the <code>emacs-standard</code> and <code>emacs-ctlx</code> keymaps only if
- Readline is starting out in <code>emacs</code> mode.
- </p>
- </dd>
- <dt><code>term</code></dt>
- <dd><p>The <code>term=</code> form may be used to include terminal-specific
- key bindings, perhaps to bind the key sequences output by the
- terminal’s function keys. The word on the right side of the
- ‘<samp>=</samp>’ is tested against both the full name of the terminal and
- the portion of the terminal name before the first ‘<samp>-</samp>’. This
- allows <code>sun</code> to match both <code>sun</code> and <code>sun-cmd</code>,
- for instance.
- </p>
- </dd>
- <dt><code>version</code></dt>
- <dd><p>The <code>version</code> test may be used to perform comparisons against
- specific Readline versions.
- The <code>version</code> expands to the current Readline version.
- The set of comparison operators includes
- ‘<samp>=</samp>’ (and ‘<samp>==</samp>’), ‘<samp>!=</samp>’, ‘<samp><=</samp>’, ‘<samp>>=</samp>’, ‘<samp><</samp>’,
- and ‘<samp>></samp>’.
- The version number supplied on the right side of the operator consists
- of a major version number, an optional decimal point, and an optional
- minor version (e.g., ‘<samp>7.1</samp>’). If the minor version is omitted, it
- is assumed to be ‘<samp>0</samp>’.
- The operator may be separated from the string <code>version</code> and
- from the version number argument by whitespace.
- The following example sets a variable if the Readline version being used
- is 7.0 or newer:
- </p><div class="example">
- <pre class="example">$if version >= 7.0
- set show-mode-in-prompt on
- $endif
- </pre></div>
-
- </dd>
- <dt><code>application</code></dt>
- <dd><p>The <var>application</var> construct is used to include
- application-specific settings. Each program using the Readline
- library sets the <var>application name</var>, and you can test for
- a particular value.
- This could be used to bind key sequences to functions useful for
- a specific program. For instance, the following command adds a
- key sequence that quotes the current or previous word in Bash:
- </p><div class="example">
- <pre class="example">$if Bash
- # Quote the current or previous word
- "\C-xq": "\eb\"\ef\""
- $endif
- </pre></div>
-
- </dd>
- <dt><code>variable</code></dt>
- <dd><p>The <var>variable</var> construct provides simple equality tests for Readline
- variables and values.
- The permitted comparison operators are ‘<samp>=</samp>’, ‘<samp>==</samp>’, and ‘<samp>!=</samp>’.
- The variable name must be separated from the comparison operator by
- whitespace; the operator may be separated from the value on the right hand
- side by whitespace.
- Both string and boolean variables may be tested. Boolean variables must be
- tested against the values <var>on</var> and <var>off</var>.
- The following example is equivalent to the <code>mode=emacs</code> test described
- above:
- </p><div class="example">
- <pre class="example">$if editing-mode == emacs
- set show-mode-in-prompt on
- $endif
- </pre></div>
- </dd>
- </dl>
-
- </dd>
- <dt><code>$endif</code></dt>
- <dd><p>This command, as seen in the previous example, terminates an
- <code>$if</code> command.
- </p>
- </dd>
- <dt><code>$else</code></dt>
- <dd><p>Commands in this branch of the <code>$if</code> directive are executed if
- the test fails.
- </p>
- </dd>
- <dt><code>$include</code></dt>
- <dd><p>This directive takes a single filename as an argument and reads commands
- and bindings from that file.
- For example, the following directive reads from <samp>/etc/inputrc</samp>:
- </p><div class="example">
- <pre class="example">$include /etc/inputrc
- </pre></div>
- </dd>
- </dl>
-
- <hr>
- <div class="header">
- <p>
- 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> [<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>
- </div>
-
-
-
- </body>
- </html>
|