fix: echo should not read stdin (Unix semantics)

This commit is contained in:
2026-03-18 19:30:55 +08:00
parent 9bac2b8cdf
commit 717b7a95e8

View File

@ -13,10 +13,9 @@ class THEcho(TextHandler):
async def handle(
self, env: TextHandlerEnvironment, istream: str | None, args: list[str]
) -> TextHandleResult:
if len(args) == 0 and istream is None:
# echo 不读 stdin只输出参数Unix 语义)
if len(args) == 0:
return TextHandleResult(1, "请在 echo 后面添加需要输出的文本")
if istream is not None:
return TextHandleResult(0, "\n".join([istream] + args))
return TextHandleResult(0, "\n".join(args))