Repository navigation
Conversation
|
GNU testsuite comparison: |
| /// clap drops that `=`, see | ||
| /// <https://github.com/uutils/coreutils/issues/2424#issuecomment-863825242>. | ||
| /// Such a value is moved to its own argument, which clap keeps verbatim. | ||
| /// Arguments after `--`, and the value of an option given as the next |
There was a problem hiding this comment.
6 lines of comment, could you please make it shorter? :)
There was a problem hiding this comment.
Shortened to two lines.
| fn split_equals_values(args: Vec<OsString>) -> Vec<OsString> { | ||
| const FLAGS: &str = "nsz"; | ||
| const SHORT_WITH_VALUE: &str = "bcdfFO"; | ||
| const LONG_WITH_VALUE: [&str; 5] = [ |
There was a problem hiding this comment.
these lists will drift from uu_app(), could we derive them from its args instead?
There was a problem hiding this comment.
Done, the short/long lists are now built from the Command's args (a value that is optional, like -w's, is left alone as before).
Merging this PR will improve performance by 20.31%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
|
|
||
| /// GNU keeps the `=` in `-d=x` as part of the value but clap drops it, so such | ||
| /// a value is moved to its own argument, which clap keeps verbatim. | ||
| fn split_equals_values(command: &Command, args: Vec<OsString>) -> Vec<OsString> { |
There was a problem hiding this comment.
are you sure there isnt a way to do that in clap ?
it s a long function :(
There was a problem hiding this comment.
I looked, but clap always drops the = after a short option (parse_short_arg in clap_builder), and there is no setting for it. Most of the length is the getopt-like scan, so that a value that looks like an option (-O -b=1) is left alone. If you prefer something short like fmt's preserve_prefix_equals, I can drop that case. Which would you like?
|
Closing this: I could not find a way to do it in clap, and the argv rewrite is too long for such a rare case. #16436 stays open in case someone sees a cleaner approach. |
Closes #16436
GNU takes everything after a short option letter as its value, so
-b=1is the invalid list=1and-O=xsets the output delimiter to=x. clap drops that=, and only-d=was special-cased. The rewrite now moves any=...value of-b,-c,-d,-f,-Fand-O(also after-n/-s/-zin the same cluster) into its own argument, which clap keeps as is. Values given as the next argument, like-O -b=1, and operands after--are not touched.