Andrew L. Moore wrote:
Here, ed reads from named pipe `<(cal)' to the editor buffer
[...]
GNU ed is not able to read from named pipes like that;

I have been looking into this and it seems like a bug in the system, maybe in the compiler, because:
  - I copied the relevant code from moe, where 'moe <(cal)' has always worked.
  - if I compile ed with g++, 'ed <(cal)' works.
  - if I run 'valgrind ed <(cal)' also works.

This is the code causing the trouble (lines 288-291 of io.c):

  if( *filename == '!' ) fp = popen( filename + 1, "r" );
  else if( !( fp = fopen( filename, "r+" ) ) && errno != ENOENT &&
           ( fp = fopen( filename, "r" ) ) && read_onlyp && !modified() )
    *read_onlyp = true;

In particular the 'fopen( filename, "r+" )' causes the output pipe from 'cal' not to close, causing the 'getc' in ed to block instead of returning EOF. I have not yet found a satisfactory workaround that a) does not block and b) sets read_only correctly.

GNU ed is not able to filter buffer lines via external commands;

I have already implemented the ex-style filter. I'll release it as soon as I find the time to do so.


Best regards,
Antonio.

Reply via email to