Blame test/pipeio2.awk

Packit 575503
# From: megaadm@rina.quantum.de
Packit 575503
# Subject: Bug report - closing down pipes which read from shell com
Packit 575503
# To: bug-gnu-utils@prep.ai.mit.edu
Packit 575503
# Date: Thu, 27 Feb 1997 23:19:16 +0100 (CET)
Packit 575503
# CC: arnold@gnu.ai.mit.edu
Packit 575503
# 
Packit 575503
# Hello people,
Packit 575503
# 
Packit 575503
# i think i found a bug or something mysterious behaviour in
Packit 575503
# gawk Version 3.0 patchlevel 0.
Packit 575503
# 
Packit 575503
# I am running on linux 2.0.25 under bash.
Packit 575503
# 
Packit 575503
# Could you please have a look at the following awk program
Packit 575503
# an let me please know, if this is what i expect it to,
Packit 575503
# namely a bug.
Packit 575503
# 
Packit 575503
# ----------- cut here --------------------------------------------
Packit 575503
BEGIN	{
Packit 575503
			# OS is linux 2.0.25
Packit 575503
			# shell is bash
Packit 575503
			# Gnu Awk (gawk) 3.0, patchlevel 0
Packit 575503
			# The command i typed on the shell was "gawk -f <this_prog> -"
Packit 575503
Packit 575503
			#com = "cal 01 1997"
Packit 575503
			com = ("cat " SRCDIR "/pipeio2.in")
Packit 575503
Packit 575503
			# Don't use empty lines, because Windows ECHO does
Packit 575503
			# something different when invoked without arguments
Packit 575503
			while ((com | getline fnam) > 0 && fnam != "") {
Packit 575503
Packit 575503
#				com_tr = "echo " fnam " | tr [0-9]. ..........."
Packit 575503
#				com_tr = "echo " fnam " | sed 's/[0-9]/./g'"
Packit 575503
				com_tr = "echo " fnam " | sed \"s/[0-9]/./g\""
Packit 575503
				# print "\'" com_tr "\'"
Packit 575503
				print "'" com_tr "'"
Packit 575503
Packit 575503
				com_tr | getline nam
Packit 575503
				print nam
Packit 575503
Packit 575503
				# please run that program and take a look at the
Packit 575503
				# output. I think this is what was expected.
Packit 575503
Packit 575503
				# Then comment in the following 4 lines and see
Packit 575503
				# what happens. I expect the first pipe "com | getline"
Packit 575503
				# not to be close, but i think this is exactly what happens
Packit 575503
				# So, is this ok ?
Packit 575503
Packit 575503
				if (close(com_tr) < 0) {
Packit 575503
					print ERRNO
Packit 575503
					break
Packit 575503
				}
Packit 575503
			}
Packit 575503
Packit 575503
			close(com)
Packit 575503
		}
Packit 575503
# ----------- cut here --------------------------------------------
Packit 575503
# 
Packit 575503
# There is another thing i do not understand.
Packit 575503
# Why doesn't the awk - command "close" reports an
Packit 575503
# error, if i would say close("abc") which i had never
Packit 575503
# openend ?
Packit 575503
# 
Packit 575503
# Regards,
Packit 575503
# Ulrich Gvbel
Packit 575503
# -- 
Packit 575503
# /********************************************************\
Packit 575503
# *     Ulrich Gvbel, goebel@quantum.de                    *
Packit 575503
# *     Quantum Gesellschaft f|r Software mbH, Dortmund    *
Packit 575503
# *     phone  : +49-231-9749-201  fax: +49-231-9749-3     *
Packit 575503
# *     private: +49-231-803994    fax: +49-231-803994     *
Packit 575503
# \********************************************************/