Entering ".." in the shell suggests bogus commands

Bug #195090 reported by Thomas Perl
16
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
Fix Released
Medium
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

Revision history for this message
Marcel Stimberg (marcelstimberg) wrote :

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

Nice one :)

Changed in command-not-found:
status: New → Confirmed
Revision history for this message
James Westby (james-w) wrote :

Hi,

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 ".."

Thanks,

James

Revision history for this message
Thomas Perl (thp) wrote :

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

Revision history for this message
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.

Revision history for this message
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)
Changed in command-not-found:
assignee: nobody → mvo
milestone: none → ubuntu-8.04-beta
Michael Vogt (mvo)
Changed in command-not-found:
status: Triaged → Fix Committed
Michael Vogt (mvo)
Changed in command-not-found:
status: Fix Committed → 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.