mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
cmd cache: check possibilities when checking if alias overrides (#4996)
* cmd cache: check possibilities when checking if alias overrides This fixes an issue on Windows where an alias could not override a command without specifying the path extension. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
c63f75efd0
commit
c07155dbe2
2 changed files with 33 additions and 3 deletions
23
news/fix-windows-alias-override.rst
Normal file
23
news/fix-windows-alias-override.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* fixed using aliases to override commands without the file extension on Windows
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -145,11 +145,18 @@ class CommandsCache(cabc.Mapping):
|
|||
|
||||
# aliases override cmds
|
||||
for cmd in self.aliases:
|
||||
key = cmd.upper() if ON_WINDOWS else cmd
|
||||
if key in all_cmds:
|
||||
# Get the possible names the alias could be overriding,
|
||||
# and check if any are in all_cmds.
|
||||
possibilities = self.get_possible_names(cmd)
|
||||
override_key = next(
|
||||
(possible for possible in possibilities if possible in all_cmds),
|
||||
None,
|
||||
)
|
||||
if override_key:
|
||||
# (path, False) -> has same named alias
|
||||
all_cmds[key] = (all_cmds[key][0], False)
|
||||
all_cmds[override_key] = (all_cmds[override_key][0], False)
|
||||
else:
|
||||
key = cmd.upper() if ON_WINDOWS else cmd
|
||||
# True -> pure alias
|
||||
all_cmds[key] = (cmd, True)
|
||||
self._cmds_cache = all_cmds
|
||||
|
|
Loading…
Add table
Reference in a new issue