All, I don't know where Andrew's analysis of GNU ed's diagnostic source comes from. Based on my analysis, it's generated by lines 198-199 of main.c. Line 198 begins an if statement which checks if the filename is empty or ends in a slash, and line 199 (the if statement's body) sets the error message to "Is a directory" and returns false (in this context, meaning the filename cannot be accessed). The error message is printed later. The code does not actually check whether the part of the string before the slash refers to a valid directory name, simply assuming anything ending with a slash is a directory.
Whether Antonio wants to expend the coding effort to do a stat call to check whether the filename is an actual directory just for proper diagnostic output is up to him. Alexander On Sat, Jan 10, 2026 at 9:00 PM Andrew L. Moore <[email protected]> wrote: > > Hi Paul, > > In the particular case of GNU ed, the diagnotic is actually reported > by the `getc' function of GNU libc. It's their fault! > > For what it's worth, GNU sed and awk provide a similar diagnostic: > > $ sed -e 1q . > sed: read error on .: Is a directory > $ gawk 'END { print "hello, world!" }' . > gawk: warning: command line argument `.' is a directory: skipped > hello, world! > $ > > Note that "EISDIR - Is a directory." is included among the POSIX list > of system error numbers and messages: > > <https://pubs.opengroup.org/onlinepubs/9799919799/> > > The One True Awk evidently discards directory arguments without any > diagnostic, as do Solaris implementations of sed and ed: > > omnios$ awk 'BEGIN { getline } END { print }' . > > omnios$ sed -e 1q . > omnios$ printf '%s\n' q | ed . > 0 > omnios$ > > If it's a question of breaking portability of scripts that parse > diagnostics, then perhaps the Solaris approach of discarding directory > arguments is the more appropriate behavior? > > > Thanks for the bug report. Forwarding it to <[email protected]>, and > > closing the coreutils bug. > > > > > > -------- Forwarded Message -------- > > Subject: bug#80158: incorrect diagnostic from ed > > Date: Thu, 8 Jan 2026 17:21:01 -0500 > > From: Douglas McIlroy > > To: [email protected] > > > > Bug exhibited by ed version 1.22.2: > > > > If FILE is not a directory, the shell command > > ed FILE/ > > yields an incorrect diagnostic, "Is a directory". > > > > Most, if not all, other utilities yield "No such file or directory". >
