At least part of the problem is that Bash's test command appears not to
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 16 Feb 2010 01:08:07 +0000 (01:08 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 16 Feb 2010 01:08:07 +0000 (01:08 +0000)
do short-circuit evaluation, so you can't do

if [ {test 1} -a {test that's not safe if test1 is false} ]
then
...
fi

so don't do that.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31894 f5534014-38df-0310-8fa8-9805f1628bb7

tools/win-setup.sh

index 2d6022ac5a6867a5aad9c6866fa569296b371430..c6a7ac01650867970e5162550d9d9a53704e01ac 100755 (executable)
@@ -54,20 +54,23 @@ find_proxy() {
        fi
 
        # ...and wget can't fetch two registry keys because...?
+       proxy_enabled=`regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyEnable 2>/dev/null | tr -d '\012'`
        #
-       # If regtool prints a blank line, $proxy_enabled will
-       # not be a zero-length string, it'll be a newline.
-       # Strip out newlines so that doesn't happen.
+       # Bash's test command appears not to use short-circuit evaluation,
+       # so
        #
-       proxy_enabled=`regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyEnable 2>/dev/null | tr -d '\012'`
-if [ -n "$proxy_enabled" ] ; then
-echo "proxy_enabled is $proxy_enabled"
-echo "In raw bytes, that's:"
-echo -n "$proxy_enabled" | od -bc
-fi
-       if [ -n "$proxy_enabled" -a "$proxy_enabled" -ne 0 ] ; then
-               export http_proxy=`regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyServer 2>/dev/null`
-               echo "Using Internet Explorer proxy settings."
+       #       -n "$proxy_enabled" -a "$proxy_enabled" -ne 0
+       #
+       # causes a complaint if "$proxy_enabled" is an empty string -
+       # the first test fails, but the second test is done anyway,
+       # and generates a complaint about the LHS of -ne not being
+       # numeric.  Therefore, we do the tests separately.
+       #
+       if [ -n "$proxy_enabled" ] ; then
+               if [ "$proxy_enabled" -ne 0 ] ; then
+                       export http_proxy=`regtool get /HKCU/Software/Microsoft/Windows/CurrentVersion/Internet\ Settings/ProxyServer 2>/dev/null`
+                       echo "Using Internet Explorer proxy settings."
+               fi
        fi
 
        if [ -z "$http_proxy" -a -z "$HTTP_PROXY" ] ; then