home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuawk.zip / test / pipeio1.awk < prev    next >
Text File  |  1997-03-19  |  1KB  |  32 lines

  1. # From dragon!gamgee.acad.emich.edu!dhw Tue Mar 18 01:12:15 1997
  2. # Return-Path: <dragon!gamgee.acad.emich.edu!dhw>
  3. # Message-ID: <m0w6owW-000IDSC@gamgee.acad.emich.edu>
  4. # Date: Mon, 17 Mar 97 20:48 CST
  5. # From: dhw@gamgee.acad.emich.edu (David H. West)
  6. # To: arnold@gnu.ai.mit.edu
  7. # Subject: gawk 3.0.2 bug report (cc of msg to bug-gnu-utils)
  8. # Status: OR
  9. # Content-Length: 869
  10. # X-Lines: 20
  11. # X-Display-Position: 2
  12. # Nature of bug: operation on a pipe side-effects a different pipe.
  13. # Observed-With: gawk 3.0.2, Linux kernel 2.0.28
  14. # Reproduce-By: running the following script, without and with the "close"
  15. #               statement uncommented.
  16. # -----------------cut here--------------------------
  17. BEGIN {FILE1="test1"; FILE2="test2"; 
  18.        print "1\n" > FILE1; close(FILE1);
  19.        print "2\n" > FILE2; close(FILE2); 
  20.        cmd1="cat " FILE1; cmd2="cat " FILE2;
  21.        #end of preparing commands which give easily-predictable output
  22.  
  23.        while( (cmd1 | getline)==1) { #terminates as file has only 1 line
  24.                                      #and we never close cmd1
  25.           cmd2 | getline L; 
  26.           #BUG: uncommenting the following line causes an infinite loop
  27.           close(cmd2);
  28.           print $0,L;
  29.           }
  30.       }
  31.