Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'wc' gnu test-suite compatibility #3678

Closed
gkalas8 opened this issue Jun 27, 2022 · 3 comments
Closed

Fix 'wc' gnu test-suite compatibility #3678

gkalas8 opened this issue Jun 27, 2022 · 3 comments
Labels
good first issue For newcomers!

Comments

@gkalas8
Copy link
Contributor

gkalas8 commented Jun 27, 2022

The wc utility is using the os_display crate's quotation function to produce quoted filenames on its output. This implementation produces slightly different values than the GNU wc's implementation. Both are valid. Sadly the automated tests will only pass using GNU's notation.
The following example demonstrates the difference.
Filename: 'a\nb' (https://github.com/coreutils/coreutils/blob/master/tests/misc/wc-files0.sh#L44) .
GNU output : 'a'$'\n''b'
uu_wc (os_display) output: $'a\nb'

The ls util implements its own quotation logic in src/uu/ls/quoting_style.rs . This implementation, with the right configuration may produce the GNU compatible output.
In addition, when in files0 mode GNU wc will never align columns. This needs to be mirrored in uu_wc as well.

Tasks:

  • Following advice on the #coreutils discord channel move the implementation from ls to uucore.
  • Use this quotation system in wc instead of os_display.
  • Do not align columns at all when in files0 mode.
@sylvestre
Copy link
Contributor

cool, are you going to work on this?

@gkalas8
Copy link
Contributor Author

gkalas8 commented Jun 27, 2022

Yes, i just pushed the patch.
#3679

@gkalas8 gkalas8 closed this as completed Jun 27, 2022
@gkalas8 gkalas8 moved this to Done in GNU Compatibility Jun 27, 2022
@tertsdiepraam
Copy link
Member

We'll close the issue once the PR has been merged ;p

@tertsdiepraam tertsdiepraam reopened this Jun 27, 2022
@tertsdiepraam tertsdiepraam linked a pull request Jun 27, 2022 that will close this issue
sylvestre pushed a commit to gkalas8/coreutils that referenced this issue Jun 30, 2022
This change will extract a utility already present in ls to uucore.
This utility is used by dir and vdir too, which are adjusted to
look it up in uucode. No further changes to ls, dir or dirv intended.

The change here largely fiddles with the output of uu_wc to match
that of GNU wc. This is the case to the extent to make unit tests
pass, however, there are differences remaining. One specific
difference I did not tackle is that GNU wc will not align the
output columns (compute_number_width() -> 1) in the specific case
of the input for --files0-from=- being a named pipe, not real stdin.
This difference can be triggered using the following two invocations.
  - wc --files0-from=- < files0 # use a named pipe, GNU does align
  - cat files0- | wc --files0-from=- # use real stdin, GNU does not
    align.
anastygnome pushed a commit to anastygnome/coreutils that referenced this issue Jul 1, 2022
This change will extract a utility already present in ls to uucore.
This utility is used by dir and vdir too, which are adjusted to
look it up in uucode. No further changes to ls, dir or dirv intended.

The change here largely fiddles with the output of uu_wc to match
that of GNU wc. This is the case to the extent to make unit tests
pass, however, there are differences remaining. One specific
difference I did not tackle is that GNU wc will not align the
output columns (compute_number_width() -> 1) in the specific case
of the input for --files0-from=- being a named pipe, not real stdin.
This difference can be triggered using the following two invocations.
  - wc --files0-from=- < files0 # use a named pipe, GNU does align
  - cat files0- | wc --files0-from=- # use real stdin, GNU does not
    align.
anastygnome pushed a commit to anastygnome/coreutils that referenced this issue Jul 1, 2022
This change will extract a utility already present in ls to uucore.
This utility is used by dir and vdir too, which are adjusted to
look it up in uucode. No further changes to ls, dir or dirv intended.

The change here largely fiddles with the output of uu_wc to match
that of GNU wc. This is the case to the extent to make unit tests
pass, however, there are differences remaining. One specific
difference I did not tackle is that GNU wc will not align the
output columns (compute_number_width() -> 1) in the specific case
of the input for --files0-from=- being a named pipe, not real stdin.
This difference can be triggered using the following two invocations.
  - wc --files0-from=- < files0 # use a named pipe, GNU does align
  - cat files0- | wc --files0-from=- # use real stdin, GNU does not
    align.
baiyuqing pushed a commit to baiyuqing/coreutils that referenced this issue Jul 10, 2022
This change will extract a utility already present in ls to uucore.
This utility is used by dir and vdir too, which are adjusted to
look it up in uucode. No further changes to ls, dir or dirv intended.

The change here largely fiddles with the output of uu_wc to match
that of GNU wc. This is the case to the extent to make unit tests
pass, however, there are differences remaining. One specific
difference I did not tackle is that GNU wc will not align the
output columns (compute_number_width() -> 1) in the specific case
of the input for --files0-from=- being a named pipe, not real stdin.
This difference can be triggered using the following two invocations.
  - wc --files0-from=- < files0 # use a named pipe, GNU does align
  - cat files0- | wc --files0-from=- # use real stdin, GNU does not
    align.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue For newcomers!
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants