mirror of
https://https.git.savannah.gnu.org/git/grep.git
synced 2026-01-27 01:44:22 +00:00
grep: make GREP_OPTIONS obsolescent
* NEWS: * doc/grep.in.1 (ENVIRONMENT_VARIABLES): * doc/grep.texi (Environment Variables): Document that GREP_OPTIONS is obsolescent now. * src/grep.c (main): Warn if GREP_OPTIONS is used. * tests/r-dot, tests/skip-device: Don't use GREP_OPTIONS.
This commit is contained in:
parent
ea4b855c11
commit
50d843674e
3
NEWS
3
NEWS
@ -29,6 +29,9 @@ GNU grep NEWS -*- outline -*-
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
The GREP_OPTIONS environment variable is now obsolescent, and grep
|
||||
now warns if it is used. Please use an alias or script instead.
|
||||
|
||||
grep --exclude-dir='FOO/' now excludes the directory FOO.
|
||||
Previously, the trailing slash meant the option was ineffective.
|
||||
|
||||
|
||||
@ -851,19 +851,13 @@ was not compiled with national language support (\s-1NLS\s0).
|
||||
.B GREP_OPTIONS
|
||||
This variable specifies default options
|
||||
to be placed in front of any explicit options.
|
||||
For example, if
|
||||
.B GREP_OPTIONS
|
||||
is
|
||||
.BR "'\-\^\-binary-files=without-match \-\^\-directories=skip'" ,
|
||||
.B grep
|
||||
behaves as if the two options
|
||||
.B \-\^\-binary\-files=without-match
|
||||
As this causes problems when writing portable scripts,
|
||||
this feature will be removed in a future release of
|
||||
.BR grep ,
|
||||
and
|
||||
.B \-\^\-directories=skip
|
||||
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.
|
||||
.B grep
|
||||
warns if it is used.
|
||||
Please use an alias or script instead.
|
||||
.TP
|
||||
.B GREP_COLOR
|
||||
This variable specifies the color used to highlight matched (non-empty) text.
|
||||
|
||||
@ -824,22 +824,9 @@ the @code{terminfo} library.
|
||||
@cindex default options environment variable
|
||||
This variable specifies default options to be placed in front of any
|
||||
explicit options.
|
||||
For example, if @env{GREP_OPTIONS} is
|
||||
@samp{--binary-files=without-match --directories=skip}, @command{grep}
|
||||
behaves as if the two options @samp{--binary-files=without-match} and
|
||||
@samp{--directories=skip} 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.
|
||||
|
||||
The @env{GREP_OPTIONS} value does not affect whether @command{grep}
|
||||
without file operands searches standard input or the working
|
||||
directory; that is affected only by command-line options. For
|
||||
example, the command @samp{grep PAT} searches standard input and the
|
||||
command @samp{grep -r PAT} searches the working directory, regardless
|
||||
of whether @env{GREP_OPTIONS} contains @option{-r}.
|
||||
As this causes problems when writing portable scripts, this feature
|
||||
will be removed in a future release of @command{grep}, and @command{grep}
|
||||
warns if it is used. Please use an alias or script instead.
|
||||
|
||||
@item GREP_COLOR
|
||||
@vindex GREP_COLOR @r{environment variable}
|
||||
|
||||
@ -1973,7 +1973,12 @@ main (int argc, char **argv)
|
||||
atexit (clean_up_stdout);
|
||||
|
||||
last_recursive = 0;
|
||||
|
||||
prepended = prepend_default_options (getenv ("GREP_OPTIONS"), &argc, &argv);
|
||||
if (prepended)
|
||||
error (0, 0, _("warning: GREP_OPTIONS is deprecated;"
|
||||
" please use an alias or script"));
|
||||
|
||||
compile = matchers[0].compile;
|
||||
execute = matchers[0].execute;
|
||||
|
||||
|
||||
@ -14,8 +14,7 @@ compare exp out || fail=1
|
||||
(cd dir && grep -r aaa < a) > out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
echo aaa > exp || framework_failure_
|
||||
(cd dir && GREP_OPTIONS=-r grep aaa < a) > out || fail=1
|
||||
(cd dir && grep -r aaa *) > out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@ -8,7 +8,4 @@
|
||||
echo foo | grep -D skip foo - || fail=1
|
||||
echo foo | grep --devices=skip foo || fail=1
|
||||
|
||||
# It's more insidious when the skip option is via the envvar:
|
||||
echo foo | GREP_OPTIONS=--devices=skip grep foo || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user