Date: Tue, 9 Jun 2009 11:08:41 -0400 (EDT) From: der Mouse <mouse@Rodents-Montreal.ORG> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/135417: man -k overrides $PATH for $PAGER Message-ID: <200906091513.LAA26385@Sparkle.Rodents-Montreal.ORG> Resent-Message-ID: <200906091530.n59FU2v6095949@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 135417 >Category: bin >Synopsis: man -k overrides $PATH for $PAGER >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jun 09 15:30:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: der Mouse >Release: FreeBSD 6.3-RELEASE i386, probably later too >Organization: Dis- >Environment: System: FreeBSD FreeBSD.Rodents.Montreal.QC.CA 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Wed Jan 16 04:45:45 UTC 2008 root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/SMP i386 Code inspection indicates presence in 7.2 (apropos,v 1.16) too. >Description: I have a private version of less, which among other things supports an option in $LESS that /usr/bin/less does not. This less is in a directory which occurs before /usr/bin in my $PATH, and my $PAGER is "less -s". In most respects this works fine. But when I run man -k, I get an error from the stock less provoked by its failure to understand this private option. (Normal use of man does not have this problem; it obeys $PAGER just fine.) This turns out to be because man -k execs apropos, which is a shell script that, as one of its first actions, prepends /bin:/usr/bin: to $PATH. While I noticed this in 6.3, inspecting http://ftp7.freebsd.org/sites/ftp.freebsd.org/pub/FreeBSD/development/FreeBSD-CVS/src/gnu/usr.bin/man/apropos/apropos.sh,v leads me to think 7.2 uses the same apropos script and thus has the same bug. >How-To-Repeat: Create a private "less" executable which is visibly different from /usr/bin/less in some way. Try using it with man -k. Here's a specific recipe, assuming "foo" does not exist: (sh syntax) $ mkdir foo $ cd foo $ cp /bin/echo less $ export PATH=`pwd`:$PATH PAGER="less -s" $ man man -s $ man -k man Note that "man man" runs the less in `pwd`, but "man -k man" runs the stock less. >Fix: I'm not sure. Perhaps save $PATH before modifying it and restore it when running $PAGER? This seems to work for me, but may not be Right. --- apropos 2008-01-15 19:31:25.000000000 -0500 +++ apropos+ 2009-06-09 10:57:43.000000000 -0400 @@ -18,6 +18,7 @@ # $FreeBSD: src/gnu/usr.bin/man/apropos/apropos.sh,v 1.16 2002/10/21 07:44:42 ru Exp $ +prepath="$PATH" PATH=/bin:/usr/bin:$PATH db=whatis # name of whatis data base grepopt='' @@ -106,6 +107,6 @@ printf -- "$line2" exit $exit_nomatch else - ( printf -- "$line2"; echo "$line"; cat ) | $PAGER + ( printf -- "$line2"; echo "$line"; cat ) | env PATH="$prepath" $PAGER fi ) /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mouse@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906091513.LAA26385>