read complete line immediately if partial line is received
This commit is contained in:
@@ -459,32 +459,36 @@ function main() {
|
|||||||
done
|
done
|
||||||
read -r -t 1 -u $STDIN buf
|
read -r -t 1 -u $STDIN buf
|
||||||
rc=$?
|
rc=$?
|
||||||
if (( rc > 128 )); then
|
if (( rc == 0 )); then
|
||||||
|
# received complete line from stdin
|
||||||
|
line=$buf
|
||||||
|
elif (( rc > 128 )); then
|
||||||
|
# read timed out, check for partial data
|
||||||
if [ -n "$buf" ]; then
|
if [ -n "$buf" ]; then
|
||||||
line+=$buf
|
echo "< $buf (partial line)" >&$DEBUGLOG
|
||||||
echo "< $buf (partial line: '$line')" >&$DEBUGLOG
|
line=$buf
|
||||||
|
# read the rest of the line
|
||||||
|
read -r -u $STDIN buf || exit 255
|
||||||
|
line+=$buf
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
elif (( rc == 0 )); then
|
|
||||||
line+=$buf
|
|
||||||
echo "< $line" >&$DEBUGLOG
|
|
||||||
else
|
else
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
echo "< $line" >&$DEBUGLOG
|
||||||
if [ -z $cmd ]; then
|
if [ -z $cmd ]; then
|
||||||
cmd=$line
|
cmd=$line
|
||||||
args=()
|
args=()
|
||||||
elif [ -z $line ]; then
|
elif [ -z $line ]; then
|
||||||
cmd=""
|
cmd=""
|
||||||
args=()
|
args=()
|
||||||
line=""
|
echo "empty argument" >&$DEBUGLOG
|
||||||
snmp_echo NONE
|
snmp_echo NONE
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
args+=("$line")
|
args+=("$line")
|
||||||
fi
|
fi
|
||||||
line=""
|
|
||||||
case "${cmd,,}" in
|
case "${cmd,,}" in
|
||||||
ping)
|
ping)
|
||||||
cmd=""
|
cmd=""
|
||||||
|
|||||||
Reference in New Issue
Block a user