sender-mac.sh: strip unwanted characters.

This apparently removes some confusion with line endings.
This commit is contained in:
Markus Hitter 2011-09-30 15:10:48 +02:00
parent f9a4495aa1
commit 8a3c8d936d
1 changed files with 13 additions and 0 deletions

View File

@ -54,6 +54,16 @@
DEV=$(echo /dev/tty.usbserial*) DEV=$(echo /dev/tty.usbserial*)
BAUD=115200 BAUD=115200
function strip_text {
STRIP_TEXT=$(echo $1 | tr -d '\r\n')
STRIP_TEXT="${STRIP_TEXT## }"
STRIP_TEXT="${STRIP_TEXT%% }"
STRIP_TEXT="${STRIP_TEXT##\t}"
STRIP_TEXT="${STRIP_TEXT%%\t}"
}
if [ "${STY}" = "" ]; then if [ "${STY}" = "" ]; then
# we're not inside a screen session, so # we're not inside a screen session, so
# create one and restart our selfs # create one and restart our selfs
@ -86,11 +96,14 @@ else
# send line by line and wait for "ok" each time # send line by line and wait for "ok" each time
exec 3<> "$1" exec 3<> "$1"
while read <&3 LINE; do while read <&3 LINE; do
strip_text "$LINE" && LINE="$STRIP_TEXT"
echo -n "$LINE" >&2 echo -n "$LINE" >&2
echo $LINE echo $LINE
OK="" OK=""
while true; do while true; do
read OK MESSAGE read OK MESSAGE
strip_text "$OK" && OK="$STRIP_TEXT"
strip_text "$MESSAGE" && MESSAGE="$STRIP_TEXT"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# probably a disconnection from screen # probably a disconnection from screen
exit exit