mirror of
https://git.busybox.net/busybox
synced 2025-08-29 13:34:41 +02:00
Make the read built-in more compatible with bash: - Return an exit code of 142 on timeout. - When the timeout expires before a newline is detected in the input bash captures the partial input. This behaviour is new since bash version 4.4. BusyBox shells had the pre-4.4 behaviour where the input was lost. Update the tests to suit and fix a couple of compiler errors in the testsuite. function old new delta builtin_read 154 174 +20 readcmd 213 228 +15 shell_builtin_read 1364 1370 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0) Total: 41 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
9 lines
456 B
Text
Executable file
9 lines
456 B
Text
Executable file
echo "X:Y:Z:" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "X:Y:Z" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "X:Y:" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "X:Y" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "X:" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "X" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo "" | (IFS=": " read x y; echo "|$x|$y|")
|
|
echo Whitespace should be trimmed too:
|
|
echo "X:Y : " | (IFS=": " read x y; echo "|$x|$y|")
|