On Tue, 17 Apr 2001 00:45:56 +1000, "Anthony Borla"
>> Can anybody tell me ,if there is any way to restrict the user to enter
>> one character as input. i.e. if I do
>> read var
>> it will read a full word.But I want that the user is not allowed to enter
>> more than
>> one character.
>> Also is it possible to accept any input without pressing <Enter>.
Using ksh93 the timed read -t option can do this elegantly.
A typeset limits input to one char and can force case and left align
in case of dribble on the space bar.
see www.kornshell.com to get opensource ksh93 from AT&T.
(thanks guys, much appreciated)
Something like this should do what you want with ksh built ins.
Not tested as I am on a dos box at present. so RTFM
typeset -Ll1 input_char
read -t2 input_char
print "you entered $input_char"