diff --git a/news/subprocess-help.rst b/news/subprocess-help.rst new file mode 100644 index 000000000..88edcc30f --- /dev/null +++ b/news/subprocess-help.rst @@ -0,0 +1,23 @@ +**Added:** + +* Open man page when requesting help for subprocess commands, e.g. using ``sh?`` + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/xonsh/built_ins.py b/xonsh/built_ins.py index 2d6579c10..07063c9ef 100644 --- a/xonsh/built_ins.py +++ b/xonsh/built_ins.py @@ -563,6 +563,11 @@ class SubprocSpec: raise XonshError(e.format(self.cmd[0])) except FileNotFoundError: cmd0 = self.cmd[0] + if len(self.cmd) == 1 and cmd0.endswith("?"): + with contextlib.suppress(OSError): + return self.cls( + ["man", cmd0.rstrip("?")], bufsize=bufsize, **kwargs + ) e = "xonsh: subprocess mode: command not found: {0}".format(cmd0) env = builtins.__xonsh__.env sug = suggest_commands(cmd0, env, builtins.aliases)