EmilyDirsh / hotwire-shell

Automatically exported from code.google.com/p/hotwire-shell
Other
0 stars 0 forks source link

Command misresolved #152

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. type in 'l'
2. hit 'return'
3.

What is the expected output? What do you see instead?
error should be reported if 'l' is not a command or alias. Howerver, it
runs 'less' command.

Please use labels and text to provide additional information.
it seems to me that, BaseCommandResolver.resolve returns the first
completion if it's executable.

Another example is:
I have git.exe and git-add.exe on my system, when i type in 'git' instead
of 'git.exe', the first completion is 'git-add.exe', so the command 'git'
is resolved to 'git-add.exe'.

Is this behavior a designed feature or a bug?

Original issue reported on code.google.com by Zeng.Shi...@gmail.com on 24 Feb 2008 at 1:50

GoogleCodeExporter commented 9 years ago

Original comment by Zeng.Shi...@gmail.com on 24 Feb 2008 at 1:51

GoogleCodeExporter commented 9 years ago
It looks like the bug is the usage of path_inexact_executable_match.  That 
function
was a bad hack I remember adding a while ago so that we'd find "python.exe" 
when one
just typed "python".

Can you try this patch?  It seems a bit better - we just check for matches of 
the
prefix too.

Original comment by cgwalt...@gmail.com on 24 Feb 2008 at 4:17

Attachments:

GoogleCodeExporter commented 9 years ago
The patch works.

But I think it's just another hack. Since on *nix system, extensions can't be 
omitted
even for executable files. Just checking basenames is not sufficient for these 
systems.

Original comment by Zeng.Shi...@gmail.com on 24 Feb 2008 at 8:46

GoogleCodeExporter commented 9 years ago
Ah, true.  Let's try to improve the old sysdep interface for this.  How about 
this patch?

Original comment by cgwalt...@gmail.com on 24 Feb 2008 at 10:11

Attachments:

GoogleCodeExporter commented 9 years ago
looks good to me.

but one more question:
Do we need to check the extension name against PATHEXT?

Original comment by Zeng.Shi...@gmail.com on 24 Feb 2008 at 11:15

GoogleCodeExporter commented 9 years ago
Yeah, we currently check PATHEXT - in fs_win32.py we do:

    def _do_get_xaccess(self):
        super(Win32File, self)._do_get_xaccess()
        self.xaccess = self.xaccess and win_exec_re.search(self.path)

and win_exec_re is generated from PATHEXT (though I just noticed we should 
probably
hook into os.environ somehow and regenerate the regexp in the case where the 
user
modifies the PATHEXT at runtime)

I've committed this patch:

Committed r1082
    M   hotwire/command.py
    M   hotwire/sysdep/fs.py
    M   hotwire/sysdep/fs_impl/fs_win32.py
    M   hotwire/sysdep/fs_impl/fs_unix.py
r1082 = cb1f4d72a2d48f652890e98a362f006d7d33c961 (git-svn)

Original comment by cgwalt...@gmail.com on 25 Feb 2008 at 3:53