line=\ ; PS4='${#line}: + '
while read line <&$((${#line}?0:3))
do : "$line"
done <<msg 3</dev/null
one nice thing about allowing shell expansions to self test
is that the shell already has mechanisms in place for the
evaluation. its doing it all the time anyway. theres almost
nothing for you to do but to let it fall into place.
For example:
${line##*[ :: i doubt very seriously the shell will read any of this :: ]*}
msg
1: + read line
59: + : 'one nice thing about allowing shell expansions to self test'
59: + read line
58: + : 'is that the shell already has mechanisms in place for the'
58: + read line
59: + : 'evaluation. its doing it all the time anyway. theres almost'
59: + read line
52: + : 'nothing for you to do but to let it fall into place.'
52: + read line
12: + : 'For example:'
12: + read line
0: + : ''
0: + read line
Alternativamente, para uma pausa imediata ao ler uma linha em branco ...
while read line && ${line:+":"} break
do : stuff
done
... funcionará bem.