Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1196480 - read does not set variable on timeout
Summary: read does not set variable on timeout
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-26 03:35 UTC by M. Kristall
Modified: 2017-02-13 07:22 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-02-11 07:59:53 UTC
Type: Bug


Attachments (Terms of Use)

Description M. Kristall 2015-02-26 03:35:20 UTC
Description of problem:
read with "-t" does not behave according to the documentation. Specifically, the documentation says:
              -t timeout…
                     If read times out, read saves any partial input read into
                     the  specified  variable  name.
but that is not happening

Version-Release number of selected component (if applicable):
$ echo $BASH_VERSION
4.3.33(1)-release

How reproducible:
always

Actual results:
$ read part < <( echo -n ye; sleep 2; echo s ); echo "part=$part"
part=yes
$ read -t 1 part < <( echo -n ye; sleep 2; echo s ); echo "part=$part"
part=

Expected results:
1. part=yes
2. part=ye

Comment 1 Ondrej Oprala 2015-07-09 06:58:38 UTC
Hey again!

This is an interesting part of working with fds.
What happens is something like this:
1. echo writes "ye" to stdout, stdout however is buffered, meaning "ye" is "stuck" in a buffer somewhere, and not yet written to the FD.
2. sleep 2; is ran inside the subshell
3. read waits for 1 second, trying to read from the descriptor given, but no complete line, or indeed no data at all is found and it times out. Omit the code after the subshell and you can check with echo ${PIPESTATUS[0]} that read really did time out (it should return 142)
4. subshell wakes up and writes "s\n" to its stdout, making the buffer flush and really writing this time. However, there's noone to read the output anymore.

I'll be closing this bugzilla for now, but thank you for the report!

Comment 2 M. Kristall 2015-07-09 08:00:20 UTC
(In reply to Ondrej Oprala from comment #1)
> Hey again!
> 
> This is an interesting part of working with fds.
> What happens is something like this:
> 1. echo writes "ye" to stdout, stdout however is buffered, meaning "ye" is
> "stuck" in a buffer somewhere, and not yet written to the FD.

Then let's make both sides of the pipe unbuffered:

$ stdbuf -i0 bash -c 'read -t 1 part; echo "part=$part"' < <( stdbuf -o0 echo -n ye; sleep 2; echo s )
part=

Still not "[saving] any partial input read" on a timeout

Comment 3 M. Kristall 2015-07-16 23:13:46 UTC
It has been one week with no reply since I provided what I think is evidence that your explanation does not rule this out as a bug, so I'm reopening this.

Comment 5 Fedora End Of Life 2016-07-19 12:52:06 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Fedora End Of Life 2016-07-19 19:44:17 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Fedora End Of Life 2016-11-24 11:29:26 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Siteshwar Vashisht 2017-02-13 07:22:26 UTC
This was fixed by rebasing bash to version 4.4 in rawhide.


Note You need to log in before you can comment on or make changes to this bug.