[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: md5sum outputs '-' when using stdin
From: |
Stephane Chazelas |
Subject: |
Re: md5sum outputs '-' when using stdin |
Date: |
Mon, 26 Aug 2019 13:04:02 +0100 |
User-agent: |
NeoMutt/20171215 |
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