function command_not_found_handle in /etc/bash.bashrc may supress command not found error message

Bug #754859 reported by Herbert Thielen
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: bash

In case a user tries to enter a command name containing white space, e.g.
$ "foo bar"
the system doesn't print an error message. Only the return code is correct (127), but nothing else is printed. This may be confusing.

The function command_not_found_handle(), which is called by bash if the command is not found, is defined in /etc/bash.bashrc and is intended to give a hint which package may contain the command the user wants to run.

But the function definition misses quotes around the program name variable ("$1"), so the white space separates this funny command to more than one word, and the python program seems not to like this.

A simple fix is attached as patch.

Tags: patch
Revision history for this message
Herbert Thielen (thielen) wrote :
Revision history for this message
Herbert Thielen (thielen) wrote :

Some examples are shown below. The first one shows the problem - no error message, but correct return code. The second one shows the expected behaviour for a not available command without white space in the command name.

rum:~$ foo\ bar

rum:~$ echo $?
127

rum:~$ foo
No command 'foo' found, did you mean:
 Command 'fio' from package 'fio' (universe)
 Command 'goo' from package 'goo' (universe)
 Command 'fop' from package 'fop' (universe)
 Command 'fox' from package 'objcryst-fox' (universe)
 Command 'xoo' from package 'xoo' (universe)
 Command 'zoo' from package 'zoo' (universe)
foo: command not found

rum:~$ echo $?
127

After applying the patch, the expected behaviour is shown:

rum:~$ "foo bar"
foo bar: command not found

rum:~$ echo $?
127

Revision history for this message
Herbert Thielen (thielen) wrote :

I forgot to mention: This was executed on kubuntu 10.10:

rum:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"

rum:~$ echo $BASH_VERSION
4.1.5(1)-release

rum:~$ dpkg -l bash
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii bash 4.1-2ubuntu4 The GNU Bourne Again SHell

tags: added: patch
Revision history for this message
Herbert Thielen (thielen) wrote :

I just tested it on ubuntu 11.04 beta with bash 4.2-0ubuntu2; same situation here.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bash - 4.2-0ubuntu4

---------------
bash (4.2-0ubuntu4) oneiric; urgency=low

  * Apply upstream patches:
    - 009: Fix segfault running `fc -l' two times in succession.
    - 010: Correctly print/reproduce here documents attached to commands
      inside compound commands.
  * Fix parsing of double doublequotes. LP: #780441.
  * /etc/bash.bashrc:
    - Fix quoting issue calling command-not-found. LP: #754859. Closes: #587185.
    - For .hushlogin file for sudo hint. LP: #672496.
  * Don't cache the value of brk between sbrk calls (Samuel Thibault).
    Closes: #614815.
 -- Matthias Klose <email address hidden> Wed, 18 May 2011 10:56:41 +0200

Changed in bash (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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