On 2026-01-11 01:21, Alexander Jones wrote:
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.

There is no need for a stat call. Just open the file and read it as usual. If that fails, diagnose the problem as usual.

The coding effort here is simple: remove the code that checks whether the file name is empty or ends in "/". This simplifies things (and makes "ed" a tiny bit smaller and faster - isn't that the point of "ed"? :-).

Proposed patch attached.

(cc'ing Doug McIlroy who originally reported the bug to a different mailing list.)
diff '--exclude=*~' -pru ed-1.22.4/main.c ed-1.22.4fix/main.c
--- ed-1.22.4/main.c	2026-01-03 03:24:07.000000000 -0800
+++ ed-1.22.4fix/main.c	2026-01-11 07:58:42.666463578 -0800
@@ -194,9 +194,6 @@ bool interactive()
 
 bool may_access_filename( const char * const name )
   {
-  const int len = strlen( name );
-  if( len <= 0 || name[len-1] == '/' )
-    { set_error_msg( "Is a directory" ); return false; }
   if( restricted_ )
     {
     if( name[0] == '!' )

Reply via email to