bugger.
All challenges/Rustmediumthe-argument-that-splits-in-two-v1
THE INVESTIGATION

The argument that splits in two

An argument quoting fast path treats expansion syntax and high bytes as safe shell-word data.

Text and parsingContextual encoding

What’s going wrong

A build helper prints shell arguments without quoting whenever it thinks they are safe. Inputs containing braces or a high-byte separator unexpectedly change how many arguments a shell sees. Do not run a shell: repair the encoder using the explicit contract below.

Each stdin line is one even-length hexadecimal argument, or - for an empty argument; at most 4096 decoded bytes overall. NUL bytes are excluded. Print a JSON array of lowercase-hex encoded quoted arguments. An argument may remain unquoted only when nonempty and every byte is ASCII alphanumeric or one of _@%+=:,./-. Otherwise wrap the complete argument in ASCII single quotes. Inside that quoted form, replace every original single quote with the five-byte sequence single-quote, double-quote, single-quote, double-quote, single-quote. Preserve every other byte exactly. Empty input means no arguments, while a line containing - means one empty argument.

This defines a canonical output, not every equivalent shell spelling. No actual commands, interactive terminal behavior or environment lookup are involved.

Expected behavior

Preserve complete argument identity across a security-sensitive encoding boundary, including empty and non-ASCII byte inputs.

Reproduction

01 Brace expansion must remain one word
7b7265642c626c75657d
["277b7265642c626c75657d27"]
02 Safe argument stays unquoted
616c7068612d312e747874
["616c7068612d312e747874"]
03 Spaces already quote the whole word
612062
["2761206227"]

Before you begin

  • Rust strings, slices and loops
  • Transfer context-specific classification to an all-bytes safety predicate rather than trusting a few familiar examples.

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.