Hello,
I am trying to catch carriage return input but with no success.
works fine when $replay is Y,y,N or n but it doesn't catch carriage return.
I've tried with ^K or ^L 'x0a' '\n' or '\r' and with $ like $'\n' or $'\r' but it doesn't work.
here is the code:
Code:
#! /bin/bash
for count in {30..1};
do
echo -en "\rWould you like to install McAfee Agent [$count] [y-Default / n]" && read -t 1 -n 1 replay;
if [[ $replay =~ ^[YyNn]$ || $replay == '\r' ]];
then
echo Replay is $replay
break
fi
done
sleep 3
echo Replay is $replay
It doesn't brake when carriage return is been pressed.
If someone has any idea I'll be glad.
Regards,
Itamar