GNU bug report logs - #23263
cat: missingfile: No such file or directory

Previous Next

Package: coreutils;

Reported by: Jonny Grant <jg <at> jguk.org>

Date: Sun, 10 Apr 2016 18:45:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23263 in the body.
You can then email your comments to 23263 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#23263; Package coreutils. (Sun, 10 Apr 2016 18:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jonny Grant <jg <at> jguk.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 10 Apr 2016 18:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jonny Grant <jg <at> jguk.org>
To: bug-coreutils <at> gnu.org
Subject: cat: missingfile: No such file or directory
Date: Sun, 10 Apr 2016 19:43:32 +0100
Hello

I noticed that cat doesn't have an accurate message in the following 
use-case:

$ cat missingfile
cat: missingfile: No such file or directory
$ mkdir testdir
$ cat testdir
cat: testdir: Is a directory

I wrote up the details of the ENOENT problem here:
http://technoramauk.blogspot.co.uk/2015/12/enoent-considered-harmful.html

Please keep my email address in any replies as I am not on this mailing 
list.

Cheers, Jonny




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 10 Apr 2016 19:02:01 GMT) Full text and rfc822 format available.

Notification sent to Jonny Grant <jg <at> jguk.org>:
bug acknowledged by developer. (Sun, 10 Apr 2016 19:02:01 GMT) Full text and rfc822 format available.

Message #10 received at 23263-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jonny Grant <jg <at> jguk.org>, 23263-done <at> debbugs.gnu.org
Subject: Re: bug#23263: cat: missingfile: No such file or directory
Date: Sun, 10 Apr 2016 12:01:09 -0700
Jonny Grant wrote:
> Hello
>
> I noticed that cat doesn't have an accurate message in the following use-case:
>
> $ cat missingfile
> cat: missingfile: No such file or directory
> $ mkdir testdir
> $ cat testdir
> cat: testdir: Is a directory

The "No such file or directory" message occurs because the operating system does 
not have a separate error code for missing directory versus missing file. In the 
example you gave, perhaps the working directory is missing (this can happen on 
some systems), or perhaps there is no file named "missingfile" in the working 
directory; the same code is returned for both situations.

This is not a coreutils issue, but is instead a kernel and C library issue. It's 
not something that coreutils can "fix", even assuming it was agreed that it was 
a bug. If it really bothers you, I suggest writing the POSIX standardization 
committee, but I should warn you that you'll need a strong argument to change 
something that has been standardized for decades.




Information forwarded to bug-coreutils <at> gnu.org:
bug#23263; Package coreutils. (Sun, 10 Apr 2016 19:42:02 GMT) Full text and rfc822 format available.

Message #13 received at 23263-done <at> debbugs.gnu.org (full text, mbox):

From: Jonny Grant <jg <at> jguk.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>, 23263-done <at> debbugs.gnu.org
Subject: Re: bug#23263: cat: missingfile: No such file or directory
Date: Sun, 10 Apr 2016 20:41:06 +0100
Hello Paul



On 10/04/16 20:01, Paul Eggert wrote:
> Jonny Grant wrote:
>> Hello
>>
>> I noticed that cat doesn't have an accurate message in the following
>> use-case:
>>
>> $ cat missingfile
>> cat: missingfile: No such file or directory
>> $ mkdir testdir
>> $ cat testdir
>> cat: testdir: Is a directory
>
> The "No such file or directory" message occurs because the operating
> system does not have a separate error code for missing directory versus
> missing file. In the example you gave, perhaps the working directory is
> missing (this can happen on some systems), or perhaps there is no file
> named "missingfile" in the working directory; the same code is returned
> for both situations.

Other GNU tools that only accept files, don't have this problem though. 
ie GNU objdump. They workaround the ENOENT problem.

jonny <at> ubuntu1404:~$ objdump -d missingfile
objdump: 'missingfile': No such file

cat doesn't ever accept directories, so it should never output a message 
mentioning directory.


> This is not a coreutils issue, but is instead a kernel and C library
> issue. It's not something that coreutils can "fix", even assuming it was
> agreed that it was a bug. If it really bothers you, I suggest writing
> the POSIX standardization committee, but I should warn you that you'll
> need a strong argument to change something that has been standardized
> for decades.

yes I agree. I feel it is something that is a POSIX deficiency, having 
the same error code for files and directories. The POSIX standard 
ideally updated to reflect the situation in the year 2016. Technology 
shouldn't be static. I don't have the influence to persuade POSIX to 
reform unfortunately.

Thank you again for your reply.

Regards, Jonny




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 09 May 2016 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 101 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.