Correctly parse mode indicators in hashsum output#673
Correctly parse mode indicators in hashsum output#673native-api wants to merge 10 commits intokellyjonbrazil:masterfrom
Conversation
In accordance with shasum(1) manpage For legacy md5, set it to blank
|
For |
|
Reference: https://linux.die.net/man/1/shasum
|
|
Dammit. I fixed a typo in the branch name and the pull request was automatically closed. |
|
Can you add some tests with the |
Accept any symbol for future-proofing
Done. |
|
(Since you seem to prefer to talk here, I've restored the erroneously-named branch, reopened this PR and closed the duplicate one. The branch name doesn't matter much, after all.) |
|
Didn't add a test for shasum The code will still accept it (it now accepts any symbol for future-proofing), I just don't think we need to specifically test for it. |
|
Looking good! Ok, I see this works because the older output has two spaces between the hash and the filename. I think this looks good, but we should change "mode" to |
Agree in the case of BSD-style ("legacy md5") output. But in the standard case, space is just another indicator symbol, same as others. Why should it get special treatment? What would we gain from introducing such inconsistency that would compensate for its drawbacks (which is, giving the user false information about the file's contents)?
Done. Left "portable" as unsupported and used it as a test case for an unsupported mode indicator. |
This reverts commit 0363ddc.
Ah, didn't realize space was another indicator. What is it an indicator for? I didn't see space defined in the documentation you referenced. Edit: Oh, I reread the docs... must have missed it with the funky quoting: Yeah, makes sense to keep the space in the raw JSON output, then. My only final concern is whether this will erroneously report every file as "text" when parsing older versions of |
What "older versions of $ find -name shasum\*.out -type f
./tests/fixtures/osx-10.14.6/shasum.out
./tests/fixtures/ubuntu-18.04/shasum-portable.out
./tests/fixtures/ubuntu-24.04/shasum-universal-bits.out |
I've checked the history of It only ever produced the standard format:
|
E.g. currently