Ubuntu

lesspipe relies on $SHELL to tell which shell it's running from

Reported by Fergal Daly on 2007-06-14
This bug report is a duplicate of:  Bug #58103: /etc/skel/.bashrc - lesspipe problem. Edit Remove
6
Affects Status Importance Assigned to Milestone
less (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: less

$SHELL is set once, on login so doesn't tell you what shell you're
currently running from. I log in to tcsh and when I execute bash as a
shell I see.

bash: setenv: command not found
bash: setenv: command not found

I traced this back to this piece of /usr/bin/lesspipe

        case "$SHELL" in
                *csh)
                        if [ $BASENAME = $LESSFILE ]; then
                                echo "setenv LESSOPEN \"$FULLPATH %s\";"
                                echo "setenv LESSCLOSE \"$FULLPATH %s %s\";"
                        else
                                echo "setenv LESSOPEN \"| $FULLPATH %s\";"
                                echo "setenv LESSCLOSE \"$FULLPATH %s %s\";"
                        fi
                        ;;
                *)
                        if [ $BASENAME = $LESSFILE ]; then
                                echo "export LESSOPEN=\"$FULLPATH %s\";"
                                echo "export LESSCLOSE=\"$FULLPATH %s %s\";"
                        else
                                echo "export LESSOPEN=\"| $FULLPATH %s\";"
                                echo "export LESSCLOSE=\"$FULLPATH %s %s\";"
                        fi
                        ;;
        esac

I'm not sure what is the right thing to do. tcsh sets $shell. Or maybe
you could monkey around with $PPID to figure it out but that seems
really icky.

jasonq (jason-quinn) wrote :

I'm another tcsh user that encountered the same "bash: setenv: command not found" errors and traced it back to the same source. Definitely a logic error in /usr/bin/lesspipe.

I have the same problem going from tcsh to bash. The reason this at all shows up is that lesspipe is called in .bashrc: The workaround below works nicely for me. Actually, looking at /etc/skel/.bashrc, a fix similar to this has already been implemented, i.e., the problem seems to be fixed for new users. :)

--- .bashrc.orig 2008-10-09 09:32:06.000000000 +0200
+++ .bashrc 2008-10-09 09:31:22.000000000 +0200
@@ -13,7 +13,7 @@
 shopt -s checkwinsize

 # make less more friendly for non-text input files, see lesspipe(1)
-[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/bash lesspipe)"

 # set variable identifying the chroot you work in (used in the prompt below)
 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then

Roy Jamison (xteejx) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering if this is still an issue for you. Can you try with the latest Ubuntu release? Thanks in advance.

Changed in less (Ubuntu):
status: New → Incomplete
Piyush Garyali (piyush-garyali) wrote :

I am getting the same problem

Rephrasing my entry from November last year:

The problem seems to be fixed for new users (at least on my 8.04 system) as the contents of /etc/skel/.bashrc has been updated to say:

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

The problem though is that this doesn't fix the problem for users that was created before this fix was done to .bashrc.... Currently, they need to manually find out why the message displays and then replace their lesspipe line with the line above...

By the way, this bug seems to be a duplicate of bug # 58103.

Roy Jamison (xteejx) wrote :

If you feel these are the same problem, I shall mark this as a duplicate of bug 58103. Any more information you can give, please do so in the other bug report, which will be the main one now. The status of that bug is further along in the chain. Thank you for reporting this, and sorry no-one got back to you sooner.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers