I have the following shell script to read lines from terminal
#!/bin/bash
while read line
do
if [ -z ${line} ]
then
break
fi
echo ${line}
done
I cannot enter more than 256 characters. The terminal doesn't allow me to do so (Terminal doesn't print anything beyond 256 characters, not even new line. only thing it allows is backspace)
$ ./echo.sh
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
Im using solaris 10 OS terminal used is putty bash version 3.2.52
Is this a limitation in bash, or putty? I know to break my input into several lines, but I need to know if there is way to overcome maximum number of characters entered for read command as input
This is limitation in the OS terminal drivers.
We normally take it completely for granted, but when you enter
hi<Backspace>ello
and press enter, the process just readshello
.The terminal driver makes this happen by storing the line in memory, and then deleting the last character in that buffer when you press Backspace. The buffer used for this has some human scale size. On Linux it's 4096 bytes, for comparison.
You can get around this by disabling line editing:
read
will now read more data at a time, but if you press Backspace, the application will actually read a backspace character instead of the final line.