Please do not reply directly to this email. All additional comments should be made in the comments box of this bug report. https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=221113 Summary: readline function in perl does not correctly set $! Product: Fedora Core Version: fc6 Platform: i386 OS/Version: Linux Status: NEW Severity: normal Priority: normal Component: perl AssignedTo: rnorwood@xxxxxxxxxx ReportedBy: wpilorz@xxxxxxxxx QAContact: dkl@xxxxxxxxxx CC: fedora-perl-devel-list@xxxxxxxxxx Description of problem: perldoc -f readline displays example code how do check for errors with readline: for (;;) { undef $!; unless (defined( $line = <> )) { die $! if $!; last; # reached EOF } # ... } Unfortunately this method no longer works as described in current perl version. I am including a short perl script readline_test.pl attempting to use that method and bash script readline_test.bash calling that perl script 16 times; input is either "1234" or "1234\n", PERLIO environment variable is set to perlio or stdio, (PERLIO=perlio is equivalent to PERLIO not set in FC6) $/ is set to undef, not modified, \2, \1024. $/ is set to a reference to value specified in environment variable CHUNKSIZE, unless it is 0 ($/ not set in this case) or negative ($/ set to undef). In correct perl implementation all 16 tests should run successfully (no die). The results included show that PERLIO=stdio is better (4 tests fail for stdio, 6 tests fail for perlio) Version-Release number of selected component (if applicable): perl-5.8.8-10 How reproducible: always Steps to Reproduce: 1. save readline_test.pl and readline_test.bash files from attachemnts into current directory 2. run the following command in the current directory bash readline_test.bash you could prefer to run bash -vx readline_test.bash to see exactly what is being run Actual results: $ bash readline_test.bash __ running readline_test.pl for stdin=1234,CHUNKSIZE=-1,PERLIO=perlio... INFO: $/ will be set to undef Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234,CHUNKSIZE=-1,PERLIO=stdio... INFO: $/ will be set to undef Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234,CHUNKSIZE=0,PERLIO=perlio... INFO: $/ will not be set Bad file descriptor at readline_test.pl line 30, <F> line 1. __ running readline_test.pl for stdin=1234,CHUNKSIZE=0,PERLIO=stdio... INFO: $/ will not be set Bad file descriptor at readline_test.pl line 30, <F> line 1. __ running readline_test.pl for stdin=1234,CHUNKSIZE=2,PERLIO=perlio... INFO: $/ will be set to 2 INFO: File /dev/stdin has been read, nbytes = 4 __ running readline_test.pl for stdin=1234,CHUNKSIZE=2,PERLIO=stdio... INFO: $/ will be set to 2 INFO: File /dev/stdin has been read, nbytes = 4 __ running readline_test.pl for stdin=1234,CHUNKSIZE=1k,PERLIO=perlio... INFO: $/ will be set to 1024 Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234,CHUNKSIZE=1k,PERLIO=stdio... INFO: $/ will be set to 1024 INFO: File /dev/stdin has been read, nbytes = 4 __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=-1,PERLIO=perlio... INFO: $/ will be set to undef Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=-1,PERLIO=stdio... INFO: $/ will be set to undef Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=0,PERLIO=perlio... INFO: $/ will not be set INFO: File /dev/stdin has been read, nbytes = 5 __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=0,PERLIO=stdio... INFO: $/ will not be set Bad file descriptor at readline_test.pl line 30, <F> line 1. __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=2,PERLIO=perlio... INFO: $/ will be set to 2 Bad file descriptor at readline_test.pl line 30, <F> chunk 3. __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=2,PERLIO=stdio... INFO: $/ will be set to 2 INFO: File /dev/stdin has been read, nbytes = 5 __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=1k,PERLIO=perlio... INFO: $/ will be set to 1024 Bad file descriptor at readline_test.pl line 30, <F> chunk 1. __ running readline_test.pl for stdin=1234\n,CHUNKSIZE=1k,PERLIO=stdio... INFO: $/ will be set to 1024 INFO: File /dev/stdin has been read, nbytes = 5 Expected results: each run of perl should complete without die and show number of bytes on input (4 for first 8 tests, 5 for remaining tests) Additional info: if PERLIO=perlio is used and there is actual I/O error in data file, the readline_test.pl dies with inappropriate error message 'Bad file descriptor' rather than 'Input/output error' im most cases. This can be easily shown with truncated ISO-9660 image file, loop mounted. Should I also include test cases for this? ------- Additional Comments From wpilorz@xxxxxxxxx 2007-01-01 18:46 EST ------- Created an attachment (id=144615) --> (https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=144615&action=view) readline_test.pl test script -- Configure bugmail: https://bugzilla.redhat.com/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.