Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Sudo doesn't preserves the command line as-is

未关闭
#117 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust

调研方向

首先,在 cmd.exe 中使用 sudo run --inline -- 重现这两对命令,并比较 GetCommandLineW() 的输出。阅读报告中引用的 CreateProcessW 命令行行为以及 Microsoft C Runtime 的解析约定。完成的标准是 inline 命令保留预期输出中所示的原始空格和嵌入引号。

由索引模型根据 Issue 内容生成。

描述

Issue-Bug Needs-Triage
Sudo for Windows version

1.0.1

Windows build number

10.0.26100.2605

Other Software
Steps to reproduce

Start the shell cmd.exe and run these commandlines.

1a)

C:\MeinPath\get-command-line.exe hello    world

1b)

sudo run --inline -- C:\MeinPath\get-command-line.exe hello    world

Replace C:\MeinPath\get-command-line.exe with path to your commandline-outputting tool.

Note the four space characters between “hello” and “world”.

2a)

C:\MeinPath\get-command-line.exe hello"    "world

2b)

sudo run --inline -- C:\MeinPath\get-command-line.exe hello"    "world
Expected Behavior

The expected output of command 1a) is:

C:\MeinPath\get-command-line.exe  hello"    "world

and of 1b):

"C:\MeinPath\get-command-line.exe" hello    world

with four spaces between “hello” and “world”!

The expected output of command 2a) is:

C:\MeinPath\get-command-line.exe  hello"    "world

and of 2b):

"C:\MeinPath\get-command-line.exe" hello"    "world

with the quote characters inbetween “hello” and “world”.

cmd preserves the command-line with all spaces, which was entered by the user, when it builds the lpCommandLine argument for CreateProcessW().

Actual Behavior

The actual behavior is, that the output of 1b) is:

"C:\MeinPath\get-command-line.exe" hello world

without four spaces between “hello” and “world”!

And the output of 2b) is actually:

"C:\MeinPath\get-command-line.exe" "hello    world"

with the quote characters around “hello world”.

See this image:

Image

Comments

The reason that I report this bug, is, that not every program on Windows uses the same logic to split commandline into multiple arguments.
The usual convetion is to do it like the Microsoft C-Runtime. But some programs like cmd.exe itself, do it differently.

If the commandline after the two dashes -- is preserved as-is, it would be the best, I think.

Another helpful program to debug these things is my Rust program "create-process-rust".

主要语言
Rust
星标
5.9k
派生
180
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/sudo 的其他 Issue

查看 microsoft/sudo 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。