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 --------------------------------------------
|
---|
19 | BEGIN {
|
---|
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 " SRCDIR "/pipeio2.in")
|
---|
27 |
|
---|
28 | while ((com | getline fnam) > 0) {
|
---|
29 |
|
---|
30 | # com_tr = "echo " fnam " | tr [0-9]. ..........."
|
---|
31 | # com_tr = "echo " fnam " | sed 's/[0-9]/./g'"
|
---|
32 | com_tr = "echo " fnam " | sed \"s/[0-9]/./g\""
|
---|
33 | # print "\'" com_tr "\'"
|
---|
34 | print "'" com_tr "'"
|
---|
35 |
|
---|
36 | com_tr | getline nam
|
---|
37 | print nam
|
---|
38 |
|
---|
39 | # please run that program and take a look at the
|
---|
40 | # output. I think this is what was expected.
|
---|
41 |
|
---|
42 | # Then comment in the following 4 lines and see
|
---|
43 | # what happens. I expect the first pipe "com | getline"
|
---|
44 | # not to be close, but i think this is exactly what happens
|
---|
45 | # So, is this ok ?
|
---|
46 |
|
---|
47 | if (close(com_tr) < 0) {
|
---|
48 | print ERRNO
|
---|
49 | break
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | close(com)
|
---|
54 | }
|
---|
55 | # ----------- cut here --------------------------------------------
|
---|
56 | #
|
---|
57 | # There is another thing i do not understand.
|
---|
58 | # Why doesn't the awk - command "close" reports an
|
---|
59 | # error, if i would say close("abc") which i had never
|
---|
60 | # openend ?
|
---|
61 | #
|
---|
62 | # Regards,
|
---|
63 | # Ulrich Gvbel
|
---|
64 | # --
|
---|
65 | # /********************************************************\
|
---|
66 | # * Ulrich Gvbel, goebel@quantum.de *
|
---|
67 | # * Quantum Gesellschaft f|r Software mbH, Dortmund *
|
---|
68 | # * phone : +49-231-9749-201 fax: +49-231-9749-3 *
|
---|
69 | # * private: +49-231-803994 fax: +49-231-803994 *
|
---|
70 | # \********************************************************/
|
---|