Fixed `$AUTO_CD` regress after previous refactoring. (#5629)

* fix autocd

* test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andy Kipp 2024-07-24 19:00:53 +02:00 committed by GitHub
parent aed574004d
commit 31e7c4204a
Failed to generate hash of commit
3 changed files with 33 additions and 1 deletions

23
news/fix_autocd.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Fixed ``$AUTO_CD`` regress after previous refactoring.
**Security:**
* <news item>

View file

@ -577,3 +577,12 @@ def test_alias_return_command_eval_inside(xession):
assert spec.cmd == ["sudo", "echo", "1"]
assert spec.alias_name == "xsudo"
assert spec.threadable is True
def test_auto_cd(xession, tmpdir):
xession.aliases["cd"] = lambda: "some_cd_alias"
dir = str(tmpdir)
with xession.env.swap(AUTO_CD=True):
spec = cmds_to_specs([[dir]], captured="object")[-1]
assert spec.alias.__name__ == "cd"
assert spec.cmd[0] == dir

View file

@ -764,7 +764,7 @@ class SubprocSpec:
):
return
self.cmd.insert(0, "cd")
self.alias = XSH.aliases.get("cd", None)
self.alias = XSH.aliases.get("cd", None)[0]
def resolve_executable_commands(self):
"""Resolve command executables, if applicable."""