bash-hackers-wiki/syntax/shellvars/index.html

37 lines
140 KiB
HTML
Raw Normal View History

<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://flokoe.github.io/bash-hackers-wiki/syntax/shellvars/ rel=canonical><link href=../redirection/ rel=prev><link href=../words/ rel=next><link rel=icon href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.5.44"><title>Special parameters and shell variables - The Bash Hackers Wiki</title><link rel=stylesheet href=../../assets/stylesheets/main.0253249f.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#special-parameters-and-shell-variables class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="The Bash Hackers Wiki" class="md-header__button md-logo" aria-label="The Bash Hackers Wiki" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> The Bash Hackers Wiki </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Special parameters and shell variables </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to dark mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media data-md-color-scheme=slate data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===pa
</code></pre></div> <p>This variable is read-only.</p> <h3 id=bashpid>BASHPID<a class=headerlink href=#bashpid title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASHPID</code></th> <th>Since:</th> <th>4.0-alpha</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer variable</td> <td>Read-only:</td> <td>yes</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>Always expands to the process ID of the current Bash process. This differs from the special parameter <code>$</code> under certain circumstances, such as subshells that do not require Bash to be re-initialized.</p> <h3 id=bash_aliases>BASH_ALIASES<a class=headerlink href=#bash_aliases title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASH_ALIASES</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>associative array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An associative array variable whose members correspond to the internal list of aliases as maintained by the alias builtin. Elements added to this array appear in the alias list; unsetting array elements cause aliases to be removed from the alias list.</p> <p>The associative key is the name of the alias as used with the <code>alias</code> builtin command.</p> <h3 id=bash_argc>BASH_ARGC<a class=headerlink href=#bash_argc title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASH_ARGC</code></th> <th>Since:</th> <th>3.0</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>only in extended debugging mode</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An array variable whose values are the number of parameters in each frame of the current Bash execution call stack.</p> <p>The number of parameters to the current subroutine (shell function or script executed with <code>.</code> or <code>source</code> builtin command) is at the top of the stack. When a subroutine is executed, the number of parameters passed is pushed onto <code>BASH_ARGC</code>.</p> <h3 id=bash_argv>BASH_ARGV<a class=headerlink href=#bash_argv title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASH_ARGV</code></th> <th>Since:</th> <th>3.0</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>only in extended debugging mode</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An array variable containing all of the parameters in the current Bash execution call stack.</p> <p>The final parameter of the last subroutine call is at the top of the stack; the first parameter of the initial call is at the bottom. When a subroutine is executed, the parameters supplied are pushed onto <code>BASH_ARGV</code>.</p> <h3 id=bash_argv0>BASH_ARGV0<a class=headerlink href=#bash_argv0 title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASH_ARGV0</code></th> <th>Since:</th> <th>5.0-alpha</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>string</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>same as <code>$0</code></td> </tr> </tbody> </table> <p>Expands to the name of the shell or shell script - as the special parameter <code>$0</code> does. Assignments to <code>BASH_ARGV0</code> causes the value to be assigned to <code>$0</code>.</p> <p>If this parameter is unset, it loses its special properties, even if subsequently reset.</p> <h3 id=bash_cmds>BASH_CMDS<a class=headerlink href=#bash_cmds title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>BASH_CMDS</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>associative array</td> <td>Read-only:</td> <td>no
</code></pre></div> <h3 id=lineno>LINENO<a class=headerlink href=#lineno title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>LINENO</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number (starting with 1) within a script or function.</p> <p>When not in a script or function, the value substituted is not guaranteed to be meaningful.</p> <p>If this parameter is unset, it loses its special properties, even if it is subsequently reset.</p> <h3 id=machtype>MACHTYPE<a class=headerlink href=#machtype title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>MACHTYPE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>system-dependent</td> </tr> </tbody> </table> <p>Automatically set to a string that fully describes the system type on which Bash is executing, in the standard GNU "cpu-company-system" format.</p> <p>Example content:</p> <div class=highlight><pre><span></span><code>x86_64-unknown-linux-gnu
</code></pre></div> <h3 id=mapfile>MAPFILE<a class=headerlink href=#mapfile title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>MAPFILE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An array variable created to hold the text read by the <a href=../../commands/builtin/mapfile/ >mapfile builtin command</a> when no variable name is supplied.</p> <h3 id=oldpwd>OLDPWD<a class=headerlink href=#oldpwd title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>OLDPWD</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The previous working directory as set by the cd command.</p> <h3 id=optarg>OPTARG<a class=headerlink href=#optarg title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>OPTARG</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The value of the last option argument processed by the <code>getopts</code> builtin command.</p> <h3 id=optind>OPTIND<a class=headerlink href=#optind title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>OPTIND</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The index of the next argument to be processed by the <code>getopts</code> builtin command.</p> <h3 id=ostype>OSTYPE<a class=headerlink href=#ostype title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>OSTYPE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>system-dependent</td> </tr> </tbody> </table> <p>Automatically set to a string that describes the operating system on which Bash is executing.</p> <p>Example content:</p> <div class=highlight><pre><span></span><code>linux-gnu
</code></pre></div> <h3 id=pipestatus>PIPESTATUS<a class=headerlink href=#pipestatus title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PIPESTATUS</code></th> <th>Since:</th> <th>2.0</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An array variable containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).</p> <h3 id=ppid>PPID<a class=headerlink href=#ppid title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PPID</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer variable</td> <td>Read-only:</td> <td>yes</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The process ID of the shell's parent process.</p> <h3 id=pwd>PWD<a class=headerlink href=#pwd title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PWD</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The current working directory as set by the <a href=../../commands/builtin/cd/ >cd builtin command</a>.</p> <h3 id=random>RANDOM<a class=headerlink href=#random title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>RANDOM</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>Each time this parameter is referenced, a random integer between 0 and 32767 is generated. The sequence of random numbers may be initialized by assigning a value to <code>RANDOM</code>.</p> <p>If this parameter is unset, it loses its special properties, even if it is subsequently reset.</p> <h3 id=readline_line>READLINE_LINE<a class=headerlink href=#readline_line title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>READLINE_LINE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The contents of the readline line buffer, for use with <code>bind -x</code>.</p> <h3 id=readline_point>READLINE_POINT<a class=headerlink href=#readline_point title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>READLINE_POINT</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The position of the insertion point in the readline line buffer, for use with <code>bind -x</code>.</p> <h3 id=reply>REPLY<a class=headerlink href=#reply title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>REPLY</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>only by the <a href=../../commands/builtin/read/ >read builtin command</a></td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>Set to the line of input read by the <a href=../../commands/builtin/read/ >read builtin command</a> when no arguments are supplied that name target variables.</p> <h3 id=seconds>SECONDS<a class=headerlink href=#seconds title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>SECONDS</code></th> <th>Since:</th> <th>unkn
</code></pre></div> <h3 id=columns>COLUMNS<a class=headerlink href=#columns title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>COLUMNS</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>on <code>|SIGWINCH</code> Default:</td> <td>n/a</td> <td></td> </tr> </tbody> </table> <p>Used by the select compound command to determine the terminal width when printing selection lists. Automatically set upon receipt of a <code>SIGWINCH</code>.</p> <h3 id=compreply>COMPREPLY<a class=headerlink href=#compreply title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>COMPREPLY</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>An array variable from which Bash reads the possible completions generated by a shell function invoked by the programmable completion facility.</p> <h3 id=emacs>EMACS<a class=headerlink href=#emacs title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>EMACS</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If Bash finds this variable in the environment when the shell starts with value "t", it assumes that the shell is running in an Emacs shell buffer and disables line editing.</p> <h3 id=env>ENV<a class=headerlink href=#env title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>ENV</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>Similar to <code>BASH_ENV</code>: Used when the shell is invoked in POSIX&reg; mode.</p> <h3 id=fcedit>FCEDIT<a class=headerlink href=#fcedit title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>FCEDIT</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The default editor for the <code>fc</code> builtin command.</p> <h3 id=fignore>FIGNORE<a class=headerlink href=#fignore title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>FIGNORE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>A colon-separated list of suffixes to ignore when performing filename completion. A filename whose suffix matches one of the entries in <code>FIGNORE</code> is excluded from the list of matched filenames.</p> <p>Example content:</p> <div class=highlight><pre><span></span><code>.o:~
</code></pre></div> <h3 id=funcnest>FUNCNEST<a class=headerlink href=#funcnest title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>FUNCNEST</code></th> <th>Since:</th> <th>4.2-alpha</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set to a numeric value greater than 0, defines a maximum function nesting level. Function invocations that exceed this nesting level will cause the current command to abort.</p> <p>Negative values, 0 or non-numeric assignments have the effect as if <code>FUNCNEST</code> was unset or empty: No nest control</p> <h3 id=globignore>GLOBIGNORE<a class=headerlink href=#globignore title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>GLOBIGNORE</code></th> <th>Since:</th> <th>2.0</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in <code>GLOBIGNORE</code>, it is removed from the list of matches.</p> <h3 id=histcontrol>HISTCONTROL<a class=headerlink href=#histcontrol title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>HISTCONTROL</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>A colon-separated list of values controlling how commands are saved on the history list:</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><code>ignorespace</code></td> <td>lines which begin with a space character are not saved in the history list</td> </tr> <tr> <td><code>ignoredups</code></td> <td>don't save lines matching the previous history entry</td> </tr> <tr> <td><code>ignoreboth</code></td> <td>short for <code>ignorespace:ignoredups</code></td> </tr> <tr> <td><code>erasedups</code></td> <td>remove all previous lines matching the current line from the history list before the current line is saved</td> </tr> </tbody> </table> <p>Any value not in the above list is ignored.</p> <p>If <code>HISTCONTROL</code> is unset, or does not include a valid value, all lines read by the shell parser are saved on the history list, subject to the value of <code>HISTIGNORE</code>. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of <code>HISTCONTROL</code>.</p> <h3 id=histfile>HISTFILE<a class=headerlink href=#histfile title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>HISTFILE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>if unset</td> <td>Default: \'\' \~/.bash_history\'\'</td> <td></td> </tr> </tbody> </table> <p>The |name of the file in which command history is saved.|</p> <p>If unset, the command history is not saved when an interactive shell exits.</p> <h3 id=histfilesize>HISTFILESIZE<a class=headerlink href=#histfilesize title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>HISTFILESIZE</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>if unset</td> <td>Default: <code>HISTSIZE</code></td> <td></td> </tr> </tbody> </table> <p>The |maximum number of lines contained in the history file.|</p> <p>When this variable is assigned a value, the history file is truncated, if necessary, by removing
</code></pre></div> <h3 id=opterr>OPTERR<a class=headerlink href=#opterr title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>OPTERR</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>yes</td> <td>Default:</td> <td>1 (set on startup)</td> </tr> </tbody> </table> <p>If set to the value 1, Bash displays error messages generated by the <code>getopts</code> builtin command.</p> <p><code>OPTERR</code> is initialized to 1 each time the shell is invoked or a shell script is executed.</p> <h3 id=path>PATH<a class=headerlink href=#path title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PATH</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>system-dependent (set on compile time)</td> </tr> </tbody> </table> <p>The search path for commands. This is a colon-separated list of directories in which the shell looks for commands.</p> <p>A zero-length (null) directory name in the value of <code>PATH</code> indicates the current directory.</p> <p>A null directory name may appear as two adjacent colons, or as an initial or trailing colon.</p> <p>There can be a static path compiled in for use in a restricted shell.</p> <h3 id=posixly_correct>POSIXLY_CORRECT<a class=headerlink href=#posixly_correct title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>POSIXLY_CORRECT</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If this variable is in the environment when Bash starts, the shell enters posix mode before reading the startup files, as if the <code>--posix</code> invocation option had been supplied.</p> <p>If it is set while the shell is running, Bash enables posix mode, as if the command <code>set -o posix</code> had been executed.</p> <h3 id=prompt_command>PROMPT_COMMAND<a class=headerlink href=#prompt_command title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PROMPT_COMMAND</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set, the value is executed as a command prior to issuing each primary prompt.</p> <h3 id=prompt_commands>PROMPT_COMMANDS<a class=headerlink href=#prompt_commands title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PROMPT_COMMANDS</code></th> <th>Since:</th> <th>5.1-alpha</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>integer indexed array</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set, each element is executed as a command prior to issuing each primary prompt (like <code>PROMPT_COMMAND</code>, just as array).</p> <h3 id=prompt_dirtrim>PROMPT_DIRTRIM<a class=headerlink href=#prompt_dirtrim title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>PROMPT_DIRTRIM</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set to a number greater than zero, the value is used as the number of trailing directory components to retain when expanding the <code>\w</code> and <code>\W</code> prompt string escapes.</p> <p>Characters removed are replaced with an ellipsis.</p> <h3 id=ps0>PS0<a class=headerlink href=#ps0 title="Permanent link">&para;</a><
</code></pre></div> <p>If the value is null, no timing information is displayed.</p> <p>A trailing newline is added when the format string is displayed.</p> <h3 id=tmout>TMOUT<a class=headerlink href=#tmout title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>TMOUT</code></th> <th>Since:</th> <th>2.05b</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set to a value greater than zero, <code>TMOUT</code> is treated as the default timeout for the <a href=../../commands/builtin/read/ >read builtin command</a>.</p> <p>The <code>select</code> command terminates if input does not arrive after <code>TMOUT</code> seconds when input is coming from a terminal.</p> <p>In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.</p> <h3 id=tmpdir>TMPDIR<a class=headerlink href=#tmpdir title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>TMPDIR</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>If set, Bash uses its value as the name of a directory in which Bash creates temporary files for the shell's use.</p> <h3 id=auto_resume>auto_resume<a class=headerlink href=#auto_resume title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>auto_resume</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>This variable controls how the shell interacts with the user and job control. If this variable is set, single word simple commands without redirections are treated as candidates for resumption of an existing stopped job. There is no ambiguity allowed; if there is more than one job beginning with the string typed, the job most recently accessed is selected. The name of a stopped job, in this context, is the command line used to start it. If set to the value exact, the string supplied must match the name of a stopped job exactly; if set to substring, the string supplied needs to match a substring of the name of a stopped job. The substring value provides functionality analogous to the %? job identifier.</p> <p>If set to any other value, the supplied string must be a prefix of a stopped job's name; this provides functionality analogous to the <code>%string</code> job identifier.</p> <h3 id=histchars>histchars<a class=headerlink href=#histchars title="Permanent link">&para;</a></h3> <table> <thead> <tr> <th>Variable:</th> <th><code>histchars</code></th> <th>Since:</th> <th>unknown</th> </tr> </thead> <tbody> <tr> <td>Type:</td> <td>normal variable</td> <td>Read-only:</td> <td>no</td> </tr> <tr> <td>Set by Bash:</td> <td>no</td> <td>Default:</td> <td>n/a</td> </tr> </tbody> </table> <p>The two or three characters which control history expansion and tokenization.</p> <p>The first character is the history expansion character, the character which signals the start of a history expansion, normally '!' (exlamation mark).</p> <p>The second character is the quick substitution character, which is used as shorthand for re-running the previous command entered, substi tuting one string for another in the command. The default is '^' (carret).</p> <p>The optional third character is the character which indicates that the remainder of the line is a comment when found as the first character of a word, normally '#' (hash mark). The history comment character causes history substitution to be skipped for the remaining words on the line. It does not necessarily cause the she
</script> <script>
var giscus = document.querySelector("script[src*=giscus]")
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"
giscus.setAttribute("data-theme", theme)
}
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark" : "light"
/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <script id=__config type=application/json>{"base": "../..", "features": ["navigation.instant", "navigation.tracking", "navigation.tabs", "navigation.sections", "navigation.top", "content.action.view", "content.action.edit", "search.suggest", "search.highlight", "content.code.copy"], "search": "../../assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script> <script src=../../assets/javascripts/bundle.83f73b43.min.js></script> </body> </html>