Skip to content

Tracking Issue for windows_process_extensions_raw_arg #92939

Description

@Xaeroxe

Feature gate: #![feature(windows_process_extensions_raw_arg)]

This is a tracking issue for the raw_arg extension to std::process::Command on Windows.

Windows programs on the lowest API layers actually aren't required to accept arguments as an array of strings.
In fact the illusion that they do accept arguments as an array of strings is mostly maintained by one function. CommandLineToArgvW. Not all programs use that function to parse arguments. Some of the programs that don't do this are really important, like cmd.exe. These programs instead read their argument as one large string, which makes them incompatible with how std::process::Command::arg passes the arguments. std::process::Command::arg assumes the program will parse the string using CommandLineToArgvW. Most of the time this is a reasonable assumption to make.

Solution: raw_arg. Strings passed via raw_arg are sent straight through with no alteration, save for inserting spaces inbetween them. Raw args are not quoted, escaped, or really anything complicated like that. This makes them compatible with Windows executable files which don't use CommandLineToArgvW.

Public API

use std::process::Command;

// This will print
// "Hello World!"
// with the quotes, which is not possible with std::process::Command and `cmd.exe`
// with the current `.arg()` method.
let cmd = Command::new("cmd.exe").raw_arg("/C echo \"Hello World!\"");

// You can also chain this
Command::new("cmd.exe")
        .raw_arg("/C")
        .raw_arg("echo")
        .raw_arg("\"Hello World!\"")

Steps / History

Unresolved Questions

  • None yet.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions