summaryrefslogtreecommitdiff
path: root/test/pipeio2.awk
blob: dbf354bf6e65eb4a02e347d6c62b28c13ca7f848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# From: megaadm@rina.quantum.de
# Subject: Bug report - closing down pipes which read from shell com
# To: bug-gnu-utils@prep.ai.mit.edu
# Date: Thu, 27 Feb 1997 23:19:16 +0100 (CET)
# CC: arnold@gnu.ai.mit.edu
# 
# Hello people,
# 
# i think i found a bug or something mysterious behaviour in
# gawk Version 3.0 patchlevel 0.
# 
# I am running on linux 2.0.25 under bash.
# 
# Could you please have a look at the following awk program
# an let me please know, if this is what i expect it to,
# namely a bug.
# 
# ----------- cut here --------------------------------------------
BEGIN	{
			# OS is linux 2.0.25
			# shell is bash
			# Gnu Awk (gawk) 3.0, patchlevel 0
			# The command i typed on the shell was "gawk -f <this_prog> -"

			#com = "cal 01 1997"
			com = ("cat " SRCDIR "/pipeio2.in")

			while ((com | getline fnam) > 0) {

#				com_tr = "echo " fnam " | tr [0-9]. ..........."
#				com_tr = "echo " fnam " | sed 's/[0-9]/./g'"
				com_tr = "echo " fnam " | sed \"s/[0-9]/./g\""
				# print "\'" com_tr "\'"
				print "'" com_tr "'"

				com_tr | getline nam
				print nam

				# please run that program and take a look at the
				# output. I think this is what was expected.

				# Then comment in the following 4 lines and see
				# what happens. I expect the first pipe "com | getline"
				# not to be close, but i think this is exactly what happens
				# So, is this ok ?

				if (close(com_tr) < 0) {
					print ERRNO
					break
				}
			}

			close(com)
		}
# ----------- cut here --------------------------------------------
# 
# There is another thing i do not understand.
# Why doesn't the awk - command "close" reports an
# error, if i would say close("abc") which i had never
# openend ?
# 
# Regards,
# Ulrich Gvbel
# -- 
# /********************************************************\
# *     Ulrich Gvbel, goebel@quantum.de                    *
# *     Quantum Gesellschaft f|r Software mbH, Dortmund    *
# *     phone  : +49-231-9749-201  fax: +49-231-9749-3     *
# *     private: +49-231-803994    fax: +49-231-803994     *
# \********************************************************/