Bug 31431

Summary: grep manpage is incorrect regarding _GNU_nonoption_argv_flags_
Product: Documentation Reporter: sec <sec>
Component: Books & ArticlesAssignee: freebsd-doc (Nobody) <doc>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description sec 2001-10-22 15:20:01 UTC
The grep manpage states under ENVIRONMENT VARIABLES:

       _N_GNU_nonoption_argv_flags_
              (Here N is grep's numeric process ID.)  If the  ith
              character  of  this environment variable's value is
              1, do not consider the ith operand of grep to be an
              option,  even if it appears to be one.  A shell can
              put this variable in the environment for each  com­
              mand  it  runs,  specifying  which operands are the
              results of file name wildcard expansion and  there­
              fore should not be treated as options.  This behav­
              ior is available only with the GNU C  library,  and
              only when POSIXLY_CORRECT is not set.

As far as I can see, this is incorrect, since out getopt() does not fetch
this environment variable.

Fix: 

remove that section from the manpage?
How-To-Repeat: 
(echo "foobar";echo "-G")|\
perl -e '
$ENV{"_".$$."_GNU_nonoption_argv_flags_"}="1";
exec "/usr/bin/grep","-G";
'

which should grep for "-G" but doesn't.

Further evidence is, that neither the source, nor the binary
contains the string "_GNU_nonoption_argv_flags_"

yoda:/usr/src/gnu/usr.bin/grep>grep _GNU_nonoption_argv_flags_ *.[ch]
yoda:/usr/src/gnu/usr.bin/grep>

and

yoda:~>ldd /usr/bin/grep
/usr/bin/grep:
        libgnuregex.so.2 => /usr/lib/libgnuregex.so.2 (0x28070000)
        libz.so.2 => /usr/lib/libz.so.2 (0x28078000)
        libc.so.4 => /usr/lib/libc.so.4 (0x28086000)

yoda:~>strings -a /usr/bin/grep /usr/lib/libgnuregex.so.2 /usr/lib/libz.so.2 /usr/lib/libc.so.4|grep _GNU_nonoption_argv_flags_
yoda:~>
Comment 1 Peter Avalos 2001-10-22 19:24:32 UTC
> fore should not be treated as options.  This behav-
> ior is available only with the GNU C  library,  and
> only when POSIXLY_CORRECT is not set.

It looks like the last sentence states that you need GNU libc, and I'm
pretty sure that's not what you're using.

--Pete
Comment 2 sec 2001-10-23 00:10:52 UTC
On Mon, Oct 22, 2001 at 01:24:32PM -0500, Peter Avalos wrote:
> > fore should not be treated as options.  This behav-
> > ior is available only with the GNU C  library,  and
> > only when POSIXLY_CORRECT is not set.
> It looks like the last sentence states that you need GNU libc, and I'm
> pretty sure that's not what you're using.

Gah. I read it twice, and this part didn't register.

I still think it is confusing, but at least it's not incorrect.

I think it should be removed anyway, or at least clarified (as BSD
doesn't have an option to use GNU libc)

CU,
    Sec
-- 
One of the main causes of the fall of the Roman Empire
was that, lacking zero, they had no way to indicate
successful termination of their C Programs.
Comment 3 ru freebsd_committer freebsd_triage 2001-11-27 08:17:27 UTC
State Changed
From-To: open->closed

glibc specific stuff was removed from the manpage.