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