bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buffered I/O and ed shell escape command


From: Antonio Diaz Diaz
Subject: Re: Buffered I/O and ed shell escape command
Date: Wed, 29 Dec 2021 17:02:48 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14

Hi Sören,

Sören Tempel wrote:
I did some experiments with the shell escape command today and noticed
that the command behavior depends on the output stream on my system:

Thank you very much for reporting this. I have fixed it by flushing stdout as in the patch below. I'll soon release a new version of ed.

--- main_loop.c~        2021-12-04 00:55:35.000000000 +0100
+++ main_loop.c         2021-12-29 16:31:03.000000000 +0100
@@ -154,7 +154,7 @@
   if( !resize_buffer( &shcmd, &shcmdsz, i + 1 ) ) return 0;
   memcpy( shcmd, buf, i );
   shcmd[i] = 0; shcmdlen = i;
-  if( replacement ) printf( "%s\n", shcmd + 1 );
+  if( replacement ) { printf( "%s\n", shcmd + 1 ); fflush( stdout ); }
   return shcmd;
   }


Alexander Jones wrote:
I wouldn't put too much stock into comparing the GNU version of ed with
OpenBSD's, since they both ultimately derive from the same implementation
(written in the early-to-mid 1990s by Andrew Moore) and thus could share
long-standing bugs. That being said, I concur with your reading of the
POSIX spec that the modified command string should be printed before the
command is executed, so this is likely a bug that should be fixed in GNU
and reported to the various BSDs.

Agreed. In spite of the many changes made in GNU ed since 2006, most of the code still comes from Andrew's implementation of 1993-1994, so this bug may be also present in BSD ed.


Best regards,
Antonio.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]