Hello Greg!
On 29/08/17 16:21, Greg Wooledge wrote:
On Tue, Aug 29, 2017 at 03:40:54PM +0300, Jonny Grant wrote:
(B) is good, but (A) and (C) are problematic below.
A)
$ cd missingdir
bash: cd: missingdir: No such file or directory
How is this a problem? It seems completely clear to me. It tells
you what program generated the error, what the program was trying to
do, what argument was given, and what the result was.
The wording is taken directly from perror() and related library calls,
as translated for your locale.
Yes, it's a known limitation of POSIX that it uses a shared error code
for both files and directors, ENOENT. Which without programmers handling
and checking the stat() flags, means the error isn't completely clear in
the case where a file or dir does exist.
Software the deals with files, can very easily report "No such file", a
lot of GNU software does. Bash should also lead by example in this area!
Why not incorporate this suggestion quickly?
$ objdump -d missing.elf
objdump: 'missing.elf': No such file
$ objdump -d mydir
objdump: Warning: 'mydir' is not an ordinary file
Likewise, software that deals with directories, or in the case of "cd"
in bash, trying to change directory, can very easily report "No such
directory"
eg another example:
$ objdump -d docs
objdump: Warning: 'docs' is not an ordinary file
wooledg:~$ grep -r 'No such file' /usr/include
/usr/include/asm-generic/errno-base.h:#define ENOENT 2 /* No
such file or directory */
/usr/include/rpcsvc/nfs_prot.x: NFSERR_NOENT=2, /* No such file or
directory */
The magic phrase "No such file or directory" tells the aware reader
that some system call failed with errno set to ENOENT.
C)
$ ./main
-bash: ./main: No such file or directory
Again, I'm not seeing the problem.
I don't think executing a directory ever works. So this could easily be
clearer.
I imagine we have spoken already for longer about this, than it would
have been to fix it.
Regards, Jonny