From owner-freebsd-bugs@FreeBSD.ORG Tue Jun 9 15:30:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB765106566C for ; Tue, 9 Jun 2009 15:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BE7058FC1F for ; Tue, 9 Jun 2009 15:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n59FU26Y095952 for ; Tue, 9 Jun 2009 15:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n59FU2v6095949; Tue, 9 Jun 2009 15:30:02 GMT (envelope-from gnats) Resent-Date: Tue, 9 Jun 2009 15:30:02 GMT Resent-Message-Id: <200906091530.n59FU2v6095949@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, der Mouse Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A77A1065672 for ; Tue, 9 Jun 2009 15:24:27 +0000 (UTC) (envelope-from mouse@Sparkle.Rodents-Montreal.ORG) Received: from Sparkle.Rodents-Montreal.ORG (Sparkle.Rodents-Montreal.ORG [216.46.5.7]) by mx1.freebsd.org (Postfix) with ESMTP id B17DE8FC13 for ; Tue, 9 Jun 2009 15:24:26 +0000 (UTC) (envelope-from mouse@Sparkle.Rodents-Montreal.ORG) Received: (from mouse@localhost) by Sparkle.Rodents-Montreal.ORG (8.8.8/8.8.8) id LAA26385; Tue, 9 Jun 2009 11:13:16 -0400 (EDT) Message-Id: <200906091513.LAA26385@Sparkle.Rodents-Montreal.ORG> Date: Tue, 9 Jun 2009 11:08:41 -0400 (EDT) From: der Mouse To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/135417: man -k overrides $PATH for $PAGER X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: der Mouse List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 15:30:03 -0000 >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: