CVSROOT: /web/grep Module name: grep Changes by: Karl Berry <karl> 09/05/24 18:43:01
Index: manual/html_node/Environment-Variables.html =================================================================== RCS file: manual/html_node/Environment-Variables.html diff -N manual/html_node/Environment-Variables.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ manual/html_node/Environment-Variables.html 24 May 2009 18:42:58 -0000 1.1 @@ -0,0 +1,237 @@ +<html lang="en"> +<head> +<title>Environment Variables - GNU Grep 2.5.4</title> +<meta http-equiv="Content-Type" content="text/html"> +<meta name="description" content="GNU Grep 2.5.4"> +<meta name="generator" content="makeinfo 4.13"> +<link title="Top" rel="start" href="index.html#Top"> +<link rel="up" href="Invoking.html#Invoking" title="Invoking"> +<link rel="prev" href="Command_002dline-Options.html#Command_002dline-Options" title="Command-line Options"> +<link rel="next" href="Exit-Status.html#Exit-Status" title="Exit Status"> +<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> +<!-- +This manual is for `grep', a pattern matching engine. + +Copyright (C) 1999, 2000, 2001, 2002, 2005, 2008, 2009 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 no Invariant Sections, with no Front-Cover Texts, + and with no Back-Cover Texts. A copy of the license is included + in the section entitled ``GNU Free Documentation License''. + --> +<meta http-equiv="Content-Style-Type" content="text/css"> +<style type="text/css"><!-- + pre.display { font-family:inherit } + pre.format { font-family:inherit } + pre.smalldisplay { font-family:inherit; font-size:smaller } + pre.smallformat { font-family:inherit; font-size:smaller } + pre.smallexample { font-size:smaller } + pre.smalllisp { font-size:smaller } + span.sc { font-variant:small-caps } + span.roman { font-family:serif; font-weight:normal; } + span.sansserif { font-family:sans-serif; font-weight:normal; } +--></style> +</head> +<body> +<div class="node"> +<a name="Environment-Variables"></a> +<p> +Next: <a rel="next" accesskey="n" href="Exit-Status.html#Exit-Status">Exit Status</a>, +Previous: <a rel="previous" accesskey="p" href="Command_002dline-Options.html#Command_002dline-Options">Command-line Options</a>, +Up: <a rel="up" accesskey="u" href="Invoking.html#Invoking">Invoking</a> +<hr> +</div> + +<h3 class="section">2.2 Environment Variables</h3> + +<p>The behavior of <samp><span class="command">grep</span></samp> is affected +by the following environment variables. + + <p>The locale for category <code>LC_</code><var>foo</var><!-- /@w --> +is specified by examining the three environment variables +<samp><span class="env">LC_ALL</span></samp>, <samp><span class="env">LC_</span><var>foo</var></samp><!-- /@w -->, and <samp><span class="env">LANG</span></samp>, +in that order. +The first of these variables that is set specifies the locale. +For example, if <samp><span class="env">LC_ALL</span></samp> is not set, +but <samp><span class="env">LC_MESSAGES</span></samp> is set to ‘<samp><span class="samp">pt_BR</span></samp>’, +then the Brazilian Portuguese locale is used +for the <code>LC_MESSAGES</code> category. +The ‘<samp><span class="samp">C</span></samp>’ locale is used if none of these environment variables are set, +if the locale catalog is not installed, +or if <samp><span class="command">grep</span></samp> was not compiled +with national language support (<span class="sc">nls</span>). + + <p><a name="index-environment-variables-126"></a> + <dl> +<dt><samp><span class="env">GREP_OPTIONS</span></samp><dd><a name="index-GREP_005fOPTIONS-_0040r_007benvironment-variable_007d-127"></a><a name="index-default-options-environment-variable-128"></a>This variable specifies default options to be placed in front of any +explicit options. +For example, if <code>GREP_OPTIONS</code> is +‘<samp><span class="samp">--binary-files=without-match --directories=skip</span></samp>’, <samp><span class="command">grep</span></samp> +behaves as if the two options ‘<samp><span class="samp">--binary-files=without-match</span></samp>’ and +‘<samp><span class="samp">--directories=skip</span></samp>’ had been specified before +any explicit options. +Option specifications are separated by +whitespace. +A backslash escapes the next character, so it can be used to +specify an option containing whitespace or a backslash. + + <br><dt><samp><span class="env">GREP_COLOR</span></samp><dd><a name="index-GREP_005fCOLOR-_0040r_007benvironment-variable_007d-129"></a><a name="index-highlight-markers-130"></a>This variable specifies the color used to highlight matched (non-empty) text. +It is deprecated in favor of <code>GREP_COLORS</code>, but still supported. +The ‘<samp><span class="samp">mt</span></samp>’, ‘<samp><span class="samp">ms</span></samp>’, and ‘<samp><span class="samp">mc</span></samp>’ capabilities of <code>GREP_COLORS</code> +have priority over it. +It can only specify the color used to highlight +the matching non-empty text in any matching line +(a selected line when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is omitted, +or a context line when ‘<samp><span class="samp">-v</span></samp>’ is specified). +The default is ‘<samp><span class="samp">01;31</span></samp>’, +which means a bold red foreground text on the terminal's default background. + + <br><dt><samp><span class="env">GREP_COLORS</span></samp><dd><a name="index-GREP_005fCOLORS-_0040r_007benvironment-variable_007d-131"></a><a name="index-highlight-markers-132"></a>This variable specifies the colors and other attributes +used to highlight various parts of the output. +Its value is a colon-separated list of capabilities +that defaults to ‘<samp><span class="samp">ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36</span></samp>’ +with the ‘<samp><span class="samp">rv</span></samp>’ and ‘<samp><span class="samp">ne</span></samp>’ boolean capabilities omitted (i.e., false). +Supported capabilities are as follows. + + <dl> +<dt><code>sl=</code><dd><a name="index-sl-GREP_005fCOLORS-_0040r_007bcapability_007d-133"></a>SGR substring for whole selected lines +(i.e., +matching lines when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is omitted, +or non-matching lines when ‘<samp><span class="samp">-v</span></samp>’ is specified). +If however the boolean ‘<samp><span class="samp">rv</span></samp>’ capability +and the ‘<samp><span class="samp">-v</span></samp>’ command-line option are both specified, +it applies to context matching lines instead. +The default is empty (i.e., the terminal's default color pair). + + <br><dt><code>cx=</code><dd><a name="index-cx-GREP_005fCOLORS-_0040r_007bcapability_007d-134"></a>SGR substring for whole context lines +(i.e., +non-matching lines when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is omitted, +or matching lines when ‘<samp><span class="samp">-v</span></samp>’ is specified). +If however the boolean ‘<samp><span class="samp">rv</span></samp>’ capability +and the ‘<samp><span class="samp">-v</span></samp>’ command-line option are both specified, +it applies to selected non-matching lines instead. +The default is empty (i.e., the terminal's default color pair). + + <br><dt><code>rv</code><dd><a name="index-rv-GREP_005fCOLORS-_0040r_007bcapability_007d-135"></a>Boolean value that reverses (swaps) the meanings of +the ‘<samp><span class="samp">sl=</span></samp>’ and ‘<samp><span class="samp">cx=</span></samp>’ capabilities +when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is specified. +The default is false (i.e., the capability is omitted). + + <br><dt><code>mt=01;31</code><dd><a name="index-mt-GREP_005fCOLORS-_0040r_007bcapability_007d-136"></a>SGR substring for matching non-empty text in any matching line +(i.e., +a selected line when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is omitted, +or a context line when ‘<samp><span class="samp">-v</span></samp>’ is specified). +Setting this is equivalent to setting both ‘<samp><span class="samp">ms=</span></samp>’ and ‘<samp><span class="samp">mc=</span></samp>’ +at once to the same value. +The default is a bold red text foreground over the current line background. + + <br><dt><code>ms=01;31</code><dd><a name="index-ms-GREP_005fCOLORS-_0040r_007bcapability_007d-137"></a>SGR substring for matching non-empty text in a selected line. +(This is only used when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is omitted.) +The effect of the ‘<samp><span class="samp">sl=</span></samp>’ (or ‘<samp><span class="samp">cx=</span></samp>’ if ‘<samp><span class="samp">rv</span></samp>’) capability +remains active when this kicks in. +The default is a bold red text foreground over the current line background. + + <br><dt><code>mc=01;31</code><dd><a name="index-mc-GREP_005fCOLORS-_0040r_007bcapability_007d-138"></a>SGR substring for matching non-empty text in a context line. +(This is only used when the ‘<samp><span class="samp">-v</span></samp>’ command-line option is specified.) +The effect of the ‘<samp><span class="samp">cx=</span></samp>’ (or ‘<samp><span class="samp">sl=</span></samp>’ if ‘<samp><span class="samp">rv</span></samp>’) capability +remains active when this kicks in. +The default is a bold red text foreground over the current line background. + + <br><dt><code>fn=35</code><dd><a name="index-fn-GREP_005fCOLORS-_0040r_007bcapability_007d-139"></a>SGR substring for file names prefixing any content line. +The default is a magenta text foreground over the terminal's default background. + + <br><dt><code>ln=32</code><dd><a name="index-ln-GREP_005fCOLORS-_0040r_007bcapability_007d-140"></a>SGR substring for line numbers prefixing any content line. +The default is a green text foreground over the terminal's default background. + + <br><dt><code>bn=32</code><dd><a name="index-bn-GREP_005fCOLORS-_0040r_007bcapability_007d-141"></a>SGR substring for byte offsets prefixing any content line. +The default is a green text foreground over the terminal's default background. + + <br><dt><code>se=36</code><dd><a name="index-fn-GREP_005fCOLORS-_0040r_007bcapability_007d-142"></a>SGR substring for separators that are inserted +between selected line fields (‘<samp><span class="samp">:</span></samp>’), +between context line fields (‘<samp><span class="samp">-</span></samp>’), +and between groups of adjacent lines +when nonzero context is specified (‘<samp><span class="samp">--</span></samp>’). +The default is a cyan text foreground over the terminal's default background. + + <br><dt><code>ne</code><dd><a name="index-ne-GREP_005fCOLORS-_0040r_007bcapability_007d-143"></a>Boolean value that prevents clearing to the end of line +using Erase in Line (EL) to Right (‘<samp><span class="samp">\33[K</span></samp>’) +each time a colorized item ends. +This is needed on terminals on which EL is not supported. +It is otherwise useful on terminals +for which the <code>back_color_erase</code> +(<code>bce</code>) boolean terminfo capability does not apply, +when the chosen highlight colors do not affect the background, +or when EL is too slow or causes too much flicker. +The default is false (i.e., the capability is omitted). +</dl> + + <p>Note that boolean capabilities have no ‘<samp><span class="samp">=</span></samp>’... part. +They are omitted (i.e., false) by default and become true when specified. + + <p>See the Select Graphic Rendition (SGR) section +in the documentation of your text terminal +for permitted values and their meaning as character attributes. +These substring values are integers in decimal representation +and can be concatenated with semicolons. +<samp><span class="command">grep</span></samp> takes care of assembling the result +into a complete SGR sequence (‘<samp><span class="samp">\33[</span></samp>’...‘<samp><span class="samp">m</span></samp>’). +Common values to concatenate include +‘<samp><span class="samp">1</span></samp>’ for bold, +‘<samp><span class="samp">4</span></samp>’ for underline, +‘<samp><span class="samp">5</span></samp>’ for blink, +‘<samp><span class="samp">7</span></samp>’ for inverse, +‘<samp><span class="samp">39</span></samp>’ for default foreground color, +‘<samp><span class="samp">30</span></samp>’ to ‘<samp><span class="samp">37</span></samp>’ for foreground colors, +‘<samp><span class="samp">90</span></samp>’ to ‘<samp><span class="samp">97</span></samp>’ for 16-color mode foreground colors, +‘<samp><span class="samp">38;5;0</span></samp>’ to ‘<samp><span class="samp">38;5;255</span></samp>’ +for 88-color and 256-color modes foreground colors, +‘<samp><span class="samp">49</span></samp>’ for default background color, +‘<samp><span class="samp">40</span></samp>’ to ‘<samp><span class="samp">47</span></samp>’ for background colors, +‘<samp><span class="samp">100</span></samp>’ to ‘<samp><span class="samp">107</span></samp>’ for 16-color mode background colors, +and ‘<samp><span class="samp">48;5;0</span></samp>’ to ‘<samp><span class="samp">48;5;255</span></samp>’ +for 88-color and 256-color modes background colors. + + <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_COLLATE</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-_0040r_007benvironment-variable_007d-144"></a><a name="index-LC_005fCOLLATE-_0040r_007benvironment-variable_007d-145"></a><a name="index-LANG-_0040r_007benvironment-variable_007d-146"></a><a name="index-character-type-147"></a><a name="index-national-language-support-148"></a><a name="index-NLS-149"></a>These variables specify the locale for the <code>LC_COLLATE</code> category, +which determines the collating sequence +used to interpret range expressions like ‘<samp><span class="samp">[a-z]</span></samp>’. + + <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_CTYPE</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-_0040r_007benvironment-variable_007d-150"></a><a name="index-LC_005fCTYPE-_0040r_007benvironment-variable_007d-151"></a><a name="index-LANG-_0040r_007benvironment-variable_007d-152"></a>These variables specify the locale for the <code>LC_CTYPE</code> category, +which determines the type of characters, +e.g., which characters are whitespace. + + <br><dt><samp><span class="env">LC_ALL</span></samp><dt><samp><span class="env">LC_MESSAGES</span></samp><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LC_005fALL-_0040r_007benvironment-variable_007d-153"></a><a name="index-LC_005fMESSAGES-_0040r_007benvironment-variable_007d-154"></a><a name="index-LANG-_0040r_007benvironment-variable_007d-155"></a><a name="index-language-of-messages-156"></a><a name="index-message-language-157"></a><a name="index-national-language-support-158"></a><a name="index-translation-of-message-language-159"></a>These variables specify the locale for the <code>LC_MESSAGES</code> category, +which determines the language that <samp><span class="command">grep</span></samp> uses for messages. +The default ‘<samp><span class="samp">C</span></samp>’ locale uses American English messages. + + <br><dt><samp><span class="env">POSIXLY_CORRECT</span></samp><dd><a name="index-POSIXLY_005fCORRECT-_0040r_007benvironment-variable_007d-160"></a>If set, <samp><span class="command">grep</span></samp> behaves as <span class="sc">posix.2</span> requires; otherwise, +<samp><span class="command">grep</span></samp> behaves more like other <span class="sc">gnu</span> programs. +<span class="sc">posix.2</span> +requires that options that +follow file names must be treated as file names; +by default, +such options are permuted to the front of the operand list +and are treated as options. +Also, +<span class="sc">posix.2</span> requires that unrecognized options be diagnosed as “illegal”, +but since they are not really against the law the default +is to diagnose them as “invalid”. +<code>POSIXLY_CORRECT</code> also disables <code>_</code><var>N</var><code>_GNU_nonoption_argv_flags_</code>, +described below. + + <br><dt><samp><span class="env">_</span><var>N</var><span class="env">_GNU_nonoption_argv_flags_</span></samp><dd><a name="index-g_t_005f_0040var_007bN_007d_005fGNU_005fnonoption_005fargv_005fflags_005f-_0040r_007benvironment-variable_007d-161"></a>(Here <var>N</var> is <samp><span class="command">grep</span></samp>'s numeric process ID.) +If the <var>i</var>th character of this environment variable's value is ‘<samp><span class="samp">1</span></samp>’, +do not consider the <var>i</var>th operand of <samp><span class="command">grep</span></samp> to be an option, +even if it appears to be one. +A shell can put this variable in the environment for each command it runs, +specifying which operands are the results of file name wildcard expansion +and therefore should not be treated as options. +This behavior is available only with the <span class="sc">gnu</span> C library, +and only when <code>POSIXLY_CORRECT</code> is not set. + + </dl> + + </body></html> +
