rhash / RHash

Great utility for computing hash sums
http://rhash.sf.net
BSD Zero Clause License
572 stars 117 forks source link

Enhance the hash checking output #208

Open Perkolator opened 2 years ago

Perkolator commented 2 years ago

When checking the hashes of a long list of files, the output is hard to read because the result of a line is appended to the end of the line, especially when filenames have varying lengths. Small example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.txt OK
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do.txt OK
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.txt No such file or directory
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.txt OK
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.txt ERR

I propose that the result of checking a file is moved to the beginning of the line.

[ OK  ] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.txt
[ OK  ] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do.txt
[ MIS ] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.txt
[ OK  ] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.txt
[ ERR ] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.txt

So much easier to read and spot the problematic lines.

Also, if possible, add colours.

output_example

(picture example from my own bash script that checks multiple checksum files recursively using RHash in the background)

AxelPetermann commented 8 months ago

I would be also interested in this feature.

AxelPetermann commented 8 months ago

@Perkolator How did you do the reformatting shown in your screenshot?

Perkolator commented 8 months ago

It's my own bash script that does that output. It's not "reformatting" RHash output, it's a 400+ line bash script that does each hash file one by one using RHash in the background, it does not output RHash output (except in case an error is detected, then my script outputs some RHash output to an error file). It's just for my use, it's not ready for publishing for everyone.. I would need to change some things in it and I really don't have time to do it now. The screenshot is just a visual example for how the "verification messages at the beginning of a line" could be implemented.

EDIT: Actually, my script, if there's only one hash file found, then it outputs normal RHash verification (no "reformatting") of the files in the hash file.. the example picture is in case more than one hash file was found, then my script outputs that what you see in the picture, just the hash files (with possible relative folder path) and if the checking went ok or not (the yellow "check" is an indicator of that this hash file is currently being checked/verified, and it turns into red "error" or green "ok" message once it's ready and proceeds to the next hash file, or ends if none left).

AxelPetermann commented 8 months ago

@Perkolator Thanks for your quick reply. Will try to come up with my own solution.

PositronicBrainlet commented 10 hours ago

Just to clarify, it's not possible to use --printf to accomplish anything like this, correct? The documentation could be a little more clear on this. I was under the mistaken impression that you could format the output of --check with it as well, but it only seems to work for hash generation.

In any case, count this as a vote for OP's suggestions.