You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shell_cmd_complete() ignores forward slashes on Windows when deciding whether text is a bare command name #1820
Found while reviewing #1812. Analysed from the code; not yet reproduced on a Windows machine.
Problem
Cmd.shell_cmd_complete() decides whether the text being completed is a bare command name (to be completed from PATH) or a path (to be completed by path_complete()) with this check:
On Windows os.path.sep is a backslash, but a forward slash (os.path.altsep) is a path separator as well. Text which uses forward slashes is therefore treated as a bare command name and sent to get_exes_in_path().
Expected consequences on Windows
shell C:/tools/my + Tab calls get_exes_in_path("C:/tools/my"). os.path.join(path_dir, "C:/tools/my") discards the PATH directory, the glob matches C:/tools/mytool.exe, and only the basename is returned. The typed C:/tools/my is replaced by mytool.exe and the directory is lost.
shell ./my + Tab searches each PATH directory for ./my* and so lists executables on PATH, not files in the current working directory.
Suggested fix
Also check os.path.altsep (when it is not None) so this text is routed to path_complete(). The comment above the check says "no ~ or path separator", which should then be true on every platform.
A test will need to run on Windows, or patch os.path.sep/os.path.altsep.
Activity