mozilla/rust — Issue #1837: getopt error with single character options
Author: mcandre
Created: 2012-02-14 03:41:04+00:00
State: open

getopt works fine for long options, but borks on short options. I've tried multiple syntaxes, including Unix and Windows CLI conventions; the [docs](http://doc.rust-lang.org/doc/std/files/getopts-rs.html) don't even suggest which one Rust getopt expects.

Code:

https://github.com/mcandre/ios7crypt/tree/master/rust

Trace:

$ make

$ ./ios7crypt --encrypt monkey
082c4340021c1c

$ ./ios7crypt -e monkey
rust: upcall fail 'bounds check', src/libstd/getopts.rs:314
rust: domain main @0x7ff608817600 root task failed
$ ./ios7crypt -emonkey
rust: upcall fail 'Argument to option 'e' missing.', ios7crypt.rs:115
rust: domain main @0x7f8dda017600 root task failed
$ ./ios7crypt -e=monkey
rust: upcall fail 'Argument to option 'e' missing.', ios7crypt.rs:115
rust: domain main @0x7fd3fa017600 root task failed
$ ./ios7crypt --e monkey
rust: upcall fail 'Unrecognized option: 'e'.', ios7crypt.rs:115
rust: domain main @0x7fe853816200 root task failed
$ ./ios7crypt /e monkey
Usage: ./ios7crypt [options]
-e --encrypt	Encrypt
-d --decrypt	Decrypt
-t --test	Unit test
-h --help	Usage
$ ./ios7crypt /e:monkey
Usage: ./ios7crypt [options]
-e --encrypt	Encrypt
-d --decrypt	Decrypt
-t --test	Unit test
-h --help	Usage
$ ./ios7crypt /e=monkey
Usage: ./ios7crypt [options]
-e --encrypt	Encrypt
-d --decrypt	Decrypt
-t --test	Unit test
-h --help	Usage