minimistjs / minimist

parse argument options
MIT License
530 stars 30 forks source link

Repeated occurence of `=` isnt handled correctly #5

Closed nhz-io closed 1 year ago

nhz-io commented 1 year ago

minimist doesn't handle correctly:

-a=b=c
{ _: [], a: 'b' }

yargs-parser does handle correctly

-a=b=c
{ _: [], a: 'b=c' }

Spawned from: https://github.com/minimistjs/minimist/issues/2#issuecomment-1279851737

shadowspawn commented 1 year ago

I think there are two bugs in this area of the code. The code is looking for an = but not restricting test to just the start of the argument, then assumes there is only one = when assigning the option value.

So the second bug is with -ab=c the b is getting ignored.

https://github.com/minimistjs/minimist/blob/980d7ac61a0b4bd552711251ac107d506b23e41f/index.js#L152

https://github.com/minimistjs/minimist/blob/980d7ac61a0b4bd552711251ac107d506b23e41f/index.js#L153