Update of /cvsroot/lastbash/lastbash
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9762
Modified Files:
lastbash
Log Message:
Improved the error detection in builtin http client.
Index: lastbash
===================================================================
RCS file: /cvsroot/lastbash/lastbash/lastbash,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- lastbash 4 Dec 2006 16:28:39 -0000 1.72
+++ lastbash 4 Dec 2006 16:32:33 -0000 1.73
@@ -402,20 +402,30 @@
REQUEST="GET $4 HTTP/1.0\r\nHost: $2:$3\r\nUser-Agent: ${PROG_TITLE}/${PROG_VER}\r\nConnection: Close\r\n\r\n"
# Map the FD no.5 to tcp connection
- exec 5<>/dev/tcp/$2/$3
- [ "$?" != "0" ] && RET="1"
-
- # Send the request
- echo -ne "${REQUEST}" >&5 2>/dev/null
- [ "$?" != "0" ] && RET="2"
-
- # Save the response to the temporary file
- dd <&5 >"${1}" 2>/dev/null
- [ "$?" != "0" ] && RET="3"
-
- # Close the connection
- exec 5>&-
- [ "$?" != "0" ] && RET="4"
+ if exec 5<>/dev/tcp/$2/$3
+ then
+ # Send the request
+ if echo -ne "${REQUEST}" >&5 2>/dev/null
+ then
+ # Save the response to the temporary file
+ if dd <&5 >"${1}" 2>/dev/null
+ then
+ # Close the connection
+ if exec 5>&-
+ then
+ RET="0"
+ else
+ RET="4"
+ fi
+ else
+ RET="3"
+ fi
+ else
+ RET="2"
+ fi
+ else
+ RET="1"
+ fi
# Return the status code
return "${RET}"
|