Subject: bug#44308: md5sum (and other *sum utils) path dependent output

From: Kamil Dudka <[email-masked]>
Date: Thu, 29 Oct 2020 16:22:29 +0100

On Thursday, October 29, 2020 11:41:03 AM CET Alessandro Forghieri wrote:
> Greetings.
> 
> Just stumbled upon this:
> 
> *# md5sum
> ./Development/rss/rss/STAGING/BATTITI_del_27_11_2016_-_Battiti_Live:_Arsene_
> Duevi\\Roberto_Zanisi.mp3 \d41d8cd98f00b204e9800998ecf8427e
> ./Development/rss/rss/STAGING/BATTITI_del_27_11_2016_-_Battiti_Live:_Arsene_
> Duevi\\Roberto_Zanisi.mp3*
> 
> *# cp
> ./Development/rss/rss/STAGING/BATTITI_del_27_11_2016_-_Battiti_Live:_Arsene_
> Duevi\\Roberto_Zanisi.mp3 /tmp/qlo
> # md5sum /tmp/qlo
> d41d8cd98f00b204e9800998ecf8427e  /tmp/qlo**
> *
> 
> IE, in the first instance a '\' character is prepended to the output.
> The file itself is an empty file, so I guess the file content is
> irrelevant to the apparent bug.
> 
> Running coreutils-8.31-6.fc30.x86_64 on Linux 5.6.13-100.fc30.x86_64+debug

This is the documented behavior of md5sum [1]:

    "Without ‘--zero’, if FILE contains a backslash or newline, the line is
    started with a backslash, and each problematic character in the file name
    is escaped with a backslash, making the output unambiguous even in the
    presence of arbitrary file names."

Kamil

[1] https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html

> To communicate, cc me, as I am not a ML subscriber.
> 
> Cheers,