rust-lang / rust-lang/rust

`Command` debug-rendering of non-printable characters in environment variables is not shell-compatible

Open
#154,982 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

When there is a non-printable character in the value of an environment variable set via Command, the Debug output looks like this:

CARGO_ENCODED_RUSTFLAGS="-Zforce-unstable-if-unmarked\u{1f}-Aunexpected_cfgs" "cargo" "build"

The \u{1f} doesn't actually have the intended effect though -- pasting this command into a shell causes the environment variable to literally contain that string instead of containing the byte 0x1F.

Apparently the correct way to encode unicode values is $'\u1f', so the debug output should ideally be

CARGO_ENCODED_RUSTFLAGS="-Zforce-unstable-if-unmarked"$'\u1f'"-Aunexpected_cfgs" "cargo" "build"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Command debug output for environment variables, focusing on how non-printable characters are escaped. Verify the corrected rendering by pasting it into a shell and checking that the environment variable contains byte 0x1F rather than the literal escape text.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.