Skip to content

The time command drops argument quoting, so it cannot time any command with a quoted argument #196

Description

@wallstop

DISCLOSURE: LLM-GENERATED TEXT

Problem

time re-joins its arguments with single spaces and re-tokenizes, so
a quoted argument is destroyed. time set-variable greet "two words"
re-enters CommandShell.RunCommand as three tokens and is rejected:
set-variable requires exactly 2 arguments.

Evidence

  • Runtime/CommandTerminal/Backend/BuiltinCommands.cs:375 -
    shell.RunCommand(JoinArguments(args)).
  • Runtime/CommandTerminal/Backend/BuiltinCommands.cs:636 -
    JoinArguments emits args[i].contents joined with ' ', dropping
    CommandArg.startQuote / endQuote.
  • Runtime/CommandTerminal/Backend/CommandShell.cs:974 - the joined
    string goes back through CommandTokenizer.Tokenize.
  • BuiltinCommands.cs:514 - set-variable is
    MinArgCount = 2, MaxArgCount = 2, so the extra token is a hard
    error, not a silently wrong value.

time help works, and only because help takes no arguments.

Why it is not one line

log-terminal and log use the same JoinArguments, and there the
developer wants the flattening: log "a b" should print a b, not
"a b". So the quoting has to be conditional on the caller, which
means either a second join method or a flag on the existing one.

The better long-term shape is for time not to re-tokenize at all - it
already has the parsed CommandArg[] and throws it away. That needs a
CommandShell entry point that takes pre-parsed arguments, which is a
larger change; decide which you want.

The same care applies to the quoting style. CommandTokenizer accepts
both "..." and '...', and escapes need to match what the tokenizer
unescapes, so the quoting and the escaping belong next to each other
rather than duplicated in a command handler.

Acceptance

time <anything the console can run without time>` produces the same
result, error messages included, and the same timing line.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions