getopts
getopts copied to clipboard
getopts only works with UTF-8 strings, cannot process non-UTF-8 filenames
See https://github.com/samuela/rustybox/pull/32#discussion_r445116643. This has been a factor in https://github.com/uutils/coreutils migrating from getopts to clap.
Same issue in a similar project that was just brought to my attention: https://github.com/google/argh/issues/33
FWIW @samuela, that looks like it's gaining a bit of traction.
If it's possible to fix this up without breakage then we'd happily accept a patch to support non-UTF8 args. Otherwise I think we'll probably have to accept the UTF8 requirement as a limitation of getopts
.
It might be possible but the field Matches::free
has type Vec<String>
so any additional path argument can't be collected into it without being valid UTF8. It would be necessary to add an additional field with type Vec<OsString>
to avoid interface breakage, this is possible as there are private fields, and some opt-in method to populate the field instead of free
.
I can provide a patch but want to know if this direction might be potentially accepted before working on it.