Wishlist: don't print anything if not connected to a terminal

Bug #212405 reported by era
4
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
Fix Released
Medium
Michael Vogt

Bug Description

Binary package hint: command-not-found

On a Gutsy box, I was dropped into a root shell when fsck failed.

In that particular situation, you probably don't want to be distracted by impertinent error messages.

I see that bug #129257 fixes the problem that the command-not-found output was being printed to standard output. However, I would additionally like to suggest that it simply stay quiet if not connected to a terminal. If the command which could not be found is being invoked from a script, the suggestion to install the missing package is rarely what is needed or expected, and even less so if the problem is with the PATH.

For the record, the single-user root shell runs with a PATH which does not include /usr/bin, and yet there are commands from /usr/bin such as lesspipe being invoked from root's standard .bashrc. Perhaps these should be conditional etc; if requested, I will file a separate bug about that.

vnix$ PATH=/sbin:/bin:/usr/games

vnix$ lesspipe
Command 'lesspipe' is available in '/usr/bin/lesspipe'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
bash: lesspipe: command not found

vnix$ eval "$(lesspipe)"
bash: lesspipe: command not found
bash: Command: command not found
bash: The: command not found

vnix$ fgrep lesspipe /root/.bashrc
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

Revision history for this message
era (era) wrote :

For the record, see also my recent follow-up to bug #129257

Revision history for this message
era (era) wrote :

I have reported a separate bug about commands in /root/.bashrc which require /usr -- bug #212413

Daniel T Chen (crimsun)
Changed in command-not-found:
importance: Undecided → Wishlist
Revision history for this message
Michael Vogt (mvo) wrote :

With the fix for #127399 it should no longer run command-not-found when in a subshell or if it does not have a terminal. As for the single user shell, here is what it outputs in karmic:

$ PATH=/sbin:/bin:/usr/games firefox
Command 'firefox' is available in '/usr/bin/firefox'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
bash: firefox: command not found

I think this is helpful advise, please reopen (or report a new bug) if you think otherwise.

Thanks,
 Michael

Changed in command-not-found (Ubuntu):
assignee: nobody → Michael Vogt (mvo)
importance: Wishlist → Medium
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.