Building some software from source, I recently encountered
checking for egrep... configure: error: no acceptable egrep could be found in /usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/xpg4/binL
and couldn’t find a solution anywhere. In the shower I remembered setting
GREP_OPTIONS in my environment. That seems to have been the problem. After
GREP_OPTIONS and obtaining the same default behavior for myself with
alias grep='grep --color=auto --perl-regexp'
the error went away. I guess configure is finding and running
/bin/grep, which is affected by the environment, but bypasses any aliases.