Re: md5sum outputs '-' when using stdin
2019-08-25 21:03:33 +0100, Stephane Chazelas: [...] > FWIW, the ast-open implementation of "wc" doesn't output that > "-" and doesn't treat "-" as meaning stdin. If you want to > "md5sum -c" stdin there, you need to use "/dev/stdin" instead of > "-". [...] Sorry, I meant "the ast-open implementation of md5sum", not "wc". That's also the md5sum builtin of the ksh93 shell when built as part of ast-open (not enabled by default unless /opt/ast/bin is ahead of /bin in $PATH). $ printf '%s\n' "${.sh.version}" Version ABIJM 93v- 2014-12-24 $ builtin md5sum $ echo test | md5sum d8e8fca2dc0f896fd7cb4cb0031ba249 I was also wrong about using /dev/stdin to be able to "check" checksums for stdin: $ echo test | md5sum /dev/stdin d8e8fca2dc0f896fd7cb4cb0031ba249 $ echo test | md5sum /dev/fd/0 d8e8fca2dc0f896fd7cb4cb0031ba249 ast-open's md5sum treats /dev/fd/0 and /dev/stdin the same way GNU md5sum treats "-". It doesn't open the /dev/fd/0 and /dev/stdin files. You'd need to use something like: $ echo test | md5sum /dev/fd//0 d8e8fca2dc0f896fd7cb4cb0031ba249 */dev/fd//0 (in which case ast-open md5sum *does* open /dev/fd/0) $ echo test | md5sum -c <(echo test | md5sum /dev/fd//0) && echo OK OK $ echo toast | md5sum -c <(echo test | md5sum /dev/fd//0) && echo OK md5sum: /dev/fd//0: checksum changed -- Stephane
Re: md5sum outputs '-' when using stdin
On 8/26/19 10:44 AM, Erik Auerswald wrote: On Sun, Aug 25, 2019 at 09:03:33PM +0100, Stephane Chazelas wrote: [...] Maybe --quiet could be used to skip outputting file names. I don't think overloading --quiet this way is helpful. Changing *sum's output format should use a new option IMHO (if one wants to add this functionality and the maintainers do not object). This has already been discussed: https://www.gnu.org/software/coreutils/rejected_requests.html#checksum "*sum --no-filename to only output the checksum. Postprocessing the output was deemed sufficient" ... pointing at: https://lists.gnu.org/archive/html/coreutils/2014-04/msg00025.html Have a nice day, Berny
Re: md5sum outputs '-' when using stdin
Hi, On Sun, Aug 25, 2019 at 09:03:33PM +0100, Stephane Chazelas wrote: > [...] > Maybe --quiet could be used to skip outputting file names. I don't think overloading --quiet this way is helpful. Changing *sum's output format should use a new option IMHO (if one wants to add this functionality and the maintainers do not object). Thanks, Erik -- Be water, my friend. -- Bruce Lee
Re: md5sum outputs '-' when using stdin
2019-08-23 10:41:01 +0100, coreut...@fastmail.com: [...] > $ echo 'hello world' | md5sum > 6f5902ac237024bdd0c176cb93063dc4 - > > What's use is the '-'? > > Obviously it indicates the file content it taken from the > standard input, but is that of any actual use? [...] It is used by md5sum -c. $ echo test | md5sum | tee s d8e8fca2dc0f896fd7cb4cb0031ba249 - $ echo test | md5sum -c s -: OK Having said that, it's far less common a usage pattern than doing: sum=$(md5sum < file) And I agree it is annoying having to strip that "-". It's the same kind of "annoying" as the length=$(wc -c < file) That has blanks around the number in many wc implementations and which GNU wc fixed. FWIW, the ast-open implementation of "wc" doesn't output that "-" and doesn't treat "-" as meaning stdin. If you want to "md5sum -c" stdin there, you need to use "/dev/stdin" instead of "-". I'd rather GNU md5sum only output "-" when "-" is passed on the command line. Maybe --quiet could be used to skip outputting file names. -- Stephane