Entering ".." in the shell suggests bogus commands

Bug #195090 reported by Thomas Perl on 2008-02-24
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
Michael Vogt

Bug Description

I accidentally found this: If you enter ".." in the bash prompt, you get the following bogus output:

thp@macbook:~$ ..
Command '..' is available in the following places
 * /bin/..
 * /usr/bin/..
 * /usr/local/bin/..
 * /sbin/..
 * /usr/sbin/..
 * /usr/local/sbin/..
 * /usr/games/..
bash: ..: command not found

Confirmed on gutsy (command-not-found/gutsy uptodate 0.2.8ubuntu2)

Nice one :)

Changed in command-not-found:
status: New → Confirmed
James Westby (james-w) wrote :


In UnifiedDataExtractor/scan there is

def get_executables(package):
    def exec_filter(item_info):
        # lib*.so* are usualy +x so we'll exclude them
        return isinstance(item_info, DebPackage.FileInfo) and item_info.is_executable() and not re.match("^lib.*\\.so.*", os.path.basename(item_info.name))
    return ["/"+item_info.name for item_info in package.items if exec_filter(item_info)]

This bug may be fixed if the exec_filter function also excludes ".."



Thomas Perl (thp) wrote :

In Python, I'd do something like "os.path.isdir(filename)"..

Zygmunt Krynicki (zyga) wrote :

hello, I'm the author of this code.

The only correct way to fix this is to patch the "existing file" detection code that looks up files already present in the filesystem. It should ignore directories.

Thomas Perl (thp) wrote :

Here is a patch that fixes the problem by ignoring directories (as suggested by Zygmunt).

Changed in command-not-found:
importance: Undecided → Medium
status: Confirmed → Triaged
Michael Vogt (mvo) on 2008-03-06
Changed in command-not-found:
assignee: nobody → mvo
milestone: none → ubuntu-8.04-beta
Michael Vogt (mvo) on 2008-03-07
Changed in command-not-found:
status: Triaged → Fix Committed
Michael Vogt (mvo) on 2008-03-13
Changed in command-not-found:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers