Bug 10101

Summary: ash read -t / --timeout does not handle 0 or fractional seconds
Product: Busybox Reporter: Trammell Hudson <hudson>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.26.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Trammell Hudson 2017-07-17 19:10:51 UTC
The busybox ash shell builtin read does not behave like bash for 'read -t 0' or for 'read -t x.y', which is documented as:

-t timeout
Cause read to time out and return failure if a complete line of input is not read within timeout seconds. timeout may be a decimal number with a fractional portion following the decimal point. This option is only effective if read is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. If timeout is 0, read returns success if input is available on the specified file descriptor, failure otherwise. The exit status is greater than 128 if the timeout is exceeded.

In the first case, busybox read waits forever with a zero timeout rather than returning immediately.

In the second case, the comment in busybox/shell/shell_common.c incorrectly implies that bash does not support fractional seconds:

#if 0 /* even bash has no -t N.NNN support */
Comment 1 Denys Vlasenko 2017-07-20 14:10:26 UTC
Fixed in git, thanks!