Am Donnerstag, 4. Januar 2018, 14:43:02 CET schrieb Greg Wooledge:
> On Thu, Jan 04, 2018 at 11:24:30AM +0100, [email protected] wrote:
> > # Bug 1?: +Option read -n1
> > - Cursor doesn't jump automaticly to next line
>
> It's not supposed to. If you want that, just do an "echo" after the
> read.
Okay, I assumed it wasn't a bug. But it's not optimal either.
Without the -n option, the read command is always terminated with a line break,
so
the following example works well.
while read -p "Select! (y/n): "; do
case "$REPLY" in
[yY]) echo "Yes selected!"; break ;;
[nN]) echo "No selected!"; break ;;
esac
done
With the -n option you have to rewrite the whole example as follows to make it
work
the same way.
while read -n1 -p "Select! (y/n): "; do
case "$REPLY" in
[yY]) echo -e "\nYes selected!"; break ;;
[nN]) echo -e "\nNo selected!"; break ;;
'') continue ;; # Here no additional
command 'echo'
*) echo ;;
esac
done
Maybe you could change this so that you only change the -n option and not the
whole construct afterwards. I see no reason why the read command should react
differently with this option.