commander icon indicating copy to clipboard operation
commander copied to clipboard

Doesn't handle negative numbers for an arg

Open jprichardson opened this issue 12 years ago • 5 comments

If you want to have a program that has a negative number for an arg, commander.c causes a segfault.

./myprog --n -5

or...

./myprog -n "-5"

Any thoughts on why?

jprichardson avatar Mar 01 '13 21:03 jprichardson

Doesn't actually crash, that's a result of my strtod code trying to convert a null value. But it does print: unrecognized flag -5.

jprichardson avatar Mar 01 '13 22:03 jprichardson

commander interprets it as a flag currently, we could special-case digits, might as well

tj avatar Mar 01 '13 22:03 tj

Seems like any value that starts with - is misinterpreted as a flag.

For example, if I pass in "--- No way jose" I get the following message:

unrecognized flag --- No way jose"

I tried wrapping it in quotes but that didn't help. Any way around this?

chrisledet avatar Dec 16 '13 17:12 chrisledet

not currently, but we should support -- for separating args

tj avatar Dec 18 '13 09:12 tj

oh we do :D

./test foo -- --stuff --here
additional args:
  - 'foo'
  - '--stuff'
  - '--here'

tj avatar Dec 18 '13 09:12 tj