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.