Re: md5sum outputs '-' when using stdin

2019-08-26 Thread Stephane Chazelas
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

2019-08-26 Thread Bernhard Voelker

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

2019-08-26 Thread Erik Auerswald
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



Some Suggestions on 'chmod' command

2019-08-26 Thread 2477441814
Dear team,


when using chmod command with '-R' option to set permissions on a directory and 
files under the directory, I found that if my changed permissions cause the 
current user to lose 'r' or 'x' permissions, then an error will be reported 
during execution, resulting in only permission modification to the directory.


The following are my suggestions:

If the user only wants to modify the permissions of the directory, he should 
not consider using the '-R' option.

If the user wants to modify the permissions of the directory and all files 
under the directory, he should consider using the '-R' option and cannot let 
the current user lose the 'r' and 'x' permissions, otherwise even the 
permissions of the directory cannot be changed (the current behavior is to 
modify at least the permissions of the directory).

If the user only wants to modify the permissions of all files under the 
directory (excluding the directory), a command like 'chmod u+x ./target_dir/*' 
may be more appropriate.



I hope you can consider my suggestion.


Best wishes,
YuLiang Liu