Hi Greg, hi *! > For bash scripts using this, I'd go a little bit fancier: > > read_line() { > if (($# == 0)) || [[ ${!#} = -* ]]; then > declare -n _rl_lastvar=REPLY > else > declare -n _rl_lastvar=${!#} > fi > read -r "$@" || test -n "$_rl_lastvar" > }
Great, thanks - this solution seems to solve more real world problems than it introduces ;-) > This intentionally skips a trailing incomplete line that has too few > fields, as in: > > ... > > The incomplete line here only has one field, so the "lastvar" (b) is > empty, and therefore the incomplete line isn't counted. I consider > this a feature, but others may not. Yes, one might discuss this... Nevertheless, am I right that this solution relies on an undocumented feature? Best regards Martin