help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: terminate read after not receiving additional input for some time


From: Marco Ippolito
Subject: Re: terminate read after not receiving additional input for some time
Date: Tue, 6 Apr 2021 05:44:15 -0300

> I think there is no efficient way. One can write a shell function something 
> like
> 
> function read-timeout {
>   local _read_timeout_buffer=

This could omit the empty string assignment as in the statement below, couldn't
it?

>   local _read_timeout_c
>   while IFS= read -t "$1" -r -n 1 _read_timeout_c || [[ $_read_timeout_c ]]; 
> do

I like the `|| [[` touch very much here, not to lose data on timeout ᕕ(՞ᗜ՞)ᕗ

>     _read_timeout_buffer+=_read_timeout_c

Suspected typo?: _read_timeout_buffer+=$_read_timeout_c

>   done
>   read "${@:2}" < "$_read_timeout_buffer"

Suspected typo?: read "${@:2}" <<< "$_read_timeout_buffer"

> }

Liked reading this function!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]