mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
Using repr(cmd)
for command not found
(#5075)
repr cmd Co-authored-by: a <1@1.1>
This commit is contained in:
parent
0c713a0c31
commit
ec378090ce
3 changed files with 26 additions and 3 deletions
23
news/not_found_repr.rst
Normal file
23
news/not_found_repr.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* The `command not found` error will show the ``repr(cmd)`` to uncover the cases when the command name has ``\n``, ``\t`` or not visible color codes and raises the error.
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -201,7 +201,7 @@ def test_on_command_not_found_fires(xession):
|
|||
subproc = SubprocSpec.build(["xonshcommandnotfound"])
|
||||
with pytest.raises(XonshError) as expected:
|
||||
subproc.run()
|
||||
assert "command not found: xonshcommandnotfound" in str(expected.value)
|
||||
assert "command not found: 'xonshcommandnotfound'" in str(expected.value)
|
||||
assert fired
|
||||
|
||||
|
||||
|
@ -223,5 +223,5 @@ def test_on_command_not_found_doesnt_fire_in_non_interactive_mode(xession):
|
|||
subproc = SubprocSpec.build(["xonshcommandnotfound"])
|
||||
with pytest.raises(XonshError) as expected:
|
||||
subproc.run()
|
||||
assert "command not found: xonshcommandnotfound" in str(expected.value)
|
||||
assert "command not found: 'xonshcommandnotfound'" in str(expected.value)
|
||||
assert not fired
|
||||
|
|
|
@ -481,7 +481,7 @@ class SubprocSpec:
|
|||
return self.cls(
|
||||
["man", cmd0.rstrip("?")], bufsize=bufsize, **kwargs
|
||||
)
|
||||
e = f"xonsh: subprocess mode: command not found: {cmd0}"
|
||||
e = f"xonsh: subprocess mode: command not found: {repr(cmd0)}"
|
||||
env = XSH.env
|
||||
sug = xt.suggest_commands(cmd0, env)
|
||||
if len(sug.strip()) > 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue