#1104211 shasum: return \sum when name of the file contains \x2d

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
root
Date:
2025-04-28 10:57:01 UTC
Severity:
normal
#1104211#5
Date:
2025-04-27 09:47:33 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

Calculating checksum on files on an ArchLinux filesystem from Debian

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

sha256sum '/usr/lib/systemd/system/system-systemd\x2dcryptsetup.slice'

   * What was the outcome of this action?

\68dc6e85631e077f2bc751352459823844911b93b7ba2afd95d96c893222bb50  /usr/lib/systemd/system/system-systemd\\x2dcryptsetup.slice

Notice the first \

   * What outcome did you expect instead?

68dc6e85631e077f2bc751352459823844911b93b7ba2afd95d96c893222bb50  /usr/lib/systemd/system/system-systemd\\x2dcryptsetup.slice

You can reproduce the bug :

echo 'test' > 'test\x2d'
for prg in sha1sum sha224sum sha256sum sha384sum sha512sum; do $prg 'test\x2d'; done

\4e1243bd22c66e76c2ba9eddc1f91394e57f9f83  test\\x2d
\52f1bf093f4b7588726035c176c0cdb4376cfea53819f1395ac9e6ec  test\\x2d
\f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2  test\\x2d
\109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d  test\\x2d
\0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123  test\\x2d

#1104211#10
Date:
2025-04-28 10:52:02 UTC
From:
To:
That's expected behavior, and distinguishes literal vs escaped back slashes.
If you would like simpler (and more robust) programmatic control of the output,
consider using the --zero option, which does not need this escaping mechanism.

Padraig