1*3ee4fc2aSCody Peter Mello# From: megaadm@rina.quantum.de 2*3ee4fc2aSCody Peter Mello# Subject: Bug report - closing down pipes which read from shell com 3*3ee4fc2aSCody Peter Mello# To: bug-gnu-utils@prep.ai.mit.edu 4*3ee4fc2aSCody Peter Mello# Date: Thu, 27 Feb 1997 23:19:16 +0100 (CET) 5*3ee4fc2aSCody Peter Mello# CC: arnold@gnu.ai.mit.edu 6*3ee4fc2aSCody Peter Mello# 7*3ee4fc2aSCody Peter Mello# Hello people, 8*3ee4fc2aSCody Peter Mello# 9*3ee4fc2aSCody Peter Mello# i think i found a bug or something mysterious behaviour in 10*3ee4fc2aSCody Peter Mello# gawk Version 3.0 patchlevel 0. 11*3ee4fc2aSCody Peter Mello# 12*3ee4fc2aSCody Peter Mello# I am running on linux 2.0.25 under bash. 13*3ee4fc2aSCody Peter Mello# 14*3ee4fc2aSCody Peter Mello# Could you please have a look at the following awk program 15*3ee4fc2aSCody Peter Mello# an let me please know, if this is what i expect it to, 16*3ee4fc2aSCody Peter Mello# namely a bug. 17*3ee4fc2aSCody Peter Mello# 18*3ee4fc2aSCody Peter Mello# ----------- cut here -------------------------------------------- 19*3ee4fc2aSCody Peter MelloBEGIN { 20*3ee4fc2aSCody Peter Mello # OS is linux 2.0.25 21*3ee4fc2aSCody Peter Mello # shell is bash 22*3ee4fc2aSCody Peter Mello # Gnu Awk (gawk) 3.0, patchlevel 0 23*3ee4fc2aSCody Peter Mello # The command i typed on the shell was "gawk -f <this_prog> -" 24*3ee4fc2aSCody Peter Mello 25*3ee4fc2aSCody Peter Mello #com = "cal 01 1997" 26*3ee4fc2aSCody Peter Mello com = ("cat pipeio2.in") 27*3ee4fc2aSCody Peter Mello 28*3ee4fc2aSCody Peter Mello # Don't use empty lines, because Windows ECHO does 29*3ee4fc2aSCody Peter Mello # something different when invoked without arguments 30*3ee4fc2aSCody Peter Mello while ((com | getline fnam) > 0 && fnam != "") { 31*3ee4fc2aSCody Peter Mello 32*3ee4fc2aSCody Peter Mello# com_tr = "echo " fnam " | tr [0-9]. ..........." 33*3ee4fc2aSCody Peter Mello# com_tr = "echo " fnam " | sed 's/[0-9]/./g'" 34*3ee4fc2aSCody Peter Mello com_tr = "echo " fnam " | sed \"s/[0-9]/./g\"" 35*3ee4fc2aSCody Peter Mello # print "\'" com_tr "\'" 36*3ee4fc2aSCody Peter Mello print "'" com_tr "'" 37*3ee4fc2aSCody Peter Mello 38*3ee4fc2aSCody Peter Mello com_tr | getline nam 39*3ee4fc2aSCody Peter Mello print nam 40*3ee4fc2aSCody Peter Mello 41*3ee4fc2aSCody Peter Mello # please run that program and take a look at the 42*3ee4fc2aSCody Peter Mello # output. I think this is what was expected. 43*3ee4fc2aSCody Peter Mello 44*3ee4fc2aSCody Peter Mello # Then comment in the following 4 lines and see 45*3ee4fc2aSCody Peter Mello # what happens. I expect the first pipe "com | getline" 46*3ee4fc2aSCody Peter Mello # not to be close, but i think this is exactly what happens 47*3ee4fc2aSCody Peter Mello # So, is this ok ? 48*3ee4fc2aSCody Peter Mello 49*3ee4fc2aSCody Peter Mello if (close(com_tr) < 0) { 50*3ee4fc2aSCody Peter Mello print ERRNO 51*3ee4fc2aSCody Peter Mello break 52*3ee4fc2aSCody Peter Mello } 53*3ee4fc2aSCody Peter Mello } 54*3ee4fc2aSCody Peter Mello 55*3ee4fc2aSCody Peter Mello close(com) 56*3ee4fc2aSCody Peter Mello } 57*3ee4fc2aSCody Peter Mello# ----------- cut here -------------------------------------------- 58*3ee4fc2aSCody Peter Mello# 59*3ee4fc2aSCody Peter Mello# There is another thing i do not understand. 60*3ee4fc2aSCody Peter Mello# Why doesn't the awk - command "close" reports an 61*3ee4fc2aSCody Peter Mello# error, if i would say close("abc") which i had never 62*3ee4fc2aSCody Peter Mello# openend ? 63*3ee4fc2aSCody Peter Mello# 64*3ee4fc2aSCody Peter Mello# Regards, 65*3ee4fc2aSCody Peter Mello# Ulrich Gvbel 66*3ee4fc2aSCody Peter Mello# -- 67*3ee4fc2aSCody Peter Mello# /********************************************************\ 68*3ee4fc2aSCody Peter Mello# * Ulrich Gvbel, goebel@quantum.de * 69*3ee4fc2aSCody Peter Mello# * Quantum Gesellschaft f|r Software mbH, Dortmund * 70*3ee4fc2aSCody Peter Mello# * phone : +49-231-9749-201 fax: +49-231-9749-3 * 71*3ee4fc2aSCody Peter Mello# * private: +49-231-803994 fax: +49-231-803994 * 72*3ee4fc2aSCody Peter Mello# \********************************************************/ 73