ThomasDickey / original-mawk

bug-reports for mawk (originally on GoogleCode)
http://invisible-island.net/mawk/mawk.html
17 stars 2 forks source link

Failed getline crashes awk script #31

Closed GoogleCodeExporter closed 11 months ago

GoogleCodeExporter commented 8 years ago
Trying to use getline on the carrier file corresponding to a disabled network 
connection causes the entire script to fail.

What steps will reproduce the problem?
1. In the shell, disable a network connection, for example 'sudo ifconfig eth1 
down'.
2. Within an awk script, execute a command of the form 'getline var < 
"/sys/class/net/eth1/carrier"'.

What is the expected output? What do you see instead?
I expect no changes in var and a return value of -1; instead the script exits.

What version of the product are you using? On what operating system?
1.3.3, on Ubuntu 14.10.1.

Please provide any additional information below.
We believe that gawk has a similar bug.

Original issue reported on code.google.com by chad.gr...@appdynamics.com on 8 May 2015 at 12:27

GoogleCodeExporter commented 8 years ago
It seems to work for me:

# This file exist on my PC: /sys/class/net/eth0/carrier
$ mawk 'BEGIN { error_code = getline var < "/sys/class/net/eth0/carrier"; print 
error_code; print var; print "continue..." }'
1
1
continue...

# This file does not exist on my PC: /sys/class/net/eth1/carrier
$ mawk 'BEGIN { error_code = getline var < "/sys/class/net/eth1/carrier"; print 
error_code; print var; print "continue..." }'
-1

continue...

The mawk verison in Ubuntu/Debian is quite old and a lot of bugfixes for open 
bugs are added in mawk from the following webpage:

http://invisible-island.net/mawk/mawk.html

Original comment by hulselma...@gmail.com on 23 Jul 2015 at 3:53

GoogleCodeExporter commented 8 years ago
OK. Thanks for looking into it!

Original comment by chad.gr...@appdynamics.com on 23 Jul 2015 at 5:12