Skip to content

parseArgs cuts an inline --key=value at the second "=" #807

Description

@tmathura

Problem

parseArgs in plugins/codex/scripts/lib/args.mjs cuts an inline --key=value at the second =:

const [rawKey, inlineValue] = token.slice(2).split("=", 2);

String.prototype.split with a limit drops the rest of the string, so everything after a second = is lost:

"--base=a=b".slice(2).split("=", 2) // [ 'base', 'a' ]

Example

/codex:review --base=feature=x reviews against feature, not feature=x. Git allows = in ref names. The same thing happens to any value option written in the --key=value form, such as --model or --cwd. The two-word form (--base feature=x) works.

Suggested fix

Split at the first = only:

const separator = token.indexOf("=");
const rawKey = separator === -1 ? token.slice(2) : token.slice(2, separator);
const inlineValue = separator === -1 ? undefined : token.slice(separator + 1);

A test that --base=a=b gives a=b, and that --base= still gives an empty value, would cover it.

Found at db52e28f4d9ded852ab3942cea316258ae4ef346 (v1.0.6). The line is the same on main. Related, but not the same: #539 quotes this line for unknown flags.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions