LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Warning from grep (https://www.linuxquestions.org/questions/slackware-14/warning-from-grep-4175528125/)

TSquaredF 12-12-2014 06:39 PM

Warning from grep
 
I use several aliases that use grep, for example:
Code:

alias lsgp="ls /var/log/packages | grep $1"
Since the recent update of grep, I have been getting this output from my alias:
Code:

$ lsgp zsh
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
zsh-5.0.2-x86_64-1

I have crawled through the man page & cannot decipher what I need to do to my alias to eliminate the warning. Some pointers, please.
Regards,
Bill

mancha 12-12-2014 07:10 PM

Hi.

Seems you're setting GREP_OPTIONS somewhere (.bashrc/.bash_profile/.zshrc, etc.) and grep is letting you know it is deprecating this.

You can check with:

Code:

$ export | grep GREP
You can replace the environment variable and add the options directly to your alias to accomplish the same thing. For example, to have
grep show the matched strings in color you can do something like:

Code:

$ alias lsgp="ls /var/log/packages | grep --color=auto $1"
If you don't want to remove GREP_OPTIONS, for whatever reason, you could instead suppress the warning with an alias like:

Code:

$ alias lsgp="ls /var/log/packages | grep $1 2>/dev/null"
--mancha

TSquaredF 12-13-2014 07:53 PM

Thanks, mancha. With your tip, I found I was setting the GREP-OPTIONS in my bashrc. I was able to modify my aliases to get the same results & eliminate the GREP-OPTIONS line.
Regards,
Bill

smitchel1099 11-09-2015 01:32 PM

put the cookies on the bottom shelf!
 
When I run the suggested command:
Code:

export | grep GREP
I indeed get 1 result:
Code:

declare -x GREP_OPTIONS="--color"
And when use the command:
unset GREP_OPTIONS
and run the first command again, there are no results.

The missing step for me is how to find out where the "declare -x" statement is originating from.

How do you find what is setting the GREP_OPTIONS env. variable in the first place?

TSquaredF 11-09-2015 03:50 PM

In my case, I think GREP_OPTIONS was being set in /etc/profile.d/coreutils-dircolors.sh. I modified my alias to the first form listed by mancha & it works perfectly. For other ls aliases, I used the LS_OPTIONS env. var., as in:
Quote:

alias ls='/bin/ls $LS_OPTIONS'
GREP_OPTIONS may be set in any of the scripts in /etc/profile.d/ or in any bash startup script.
Regards,
Bill


All times are GMT -5. The time now is 09:11 AM.