[sage-devel] 'set -e' used inappropriately in python-2.6.2.p4
The following problem, which is ticket http://trac.sagemath.org/sage_trac/ticket/7645 is one more example of where trying to build Sage on an uncommon platform (HP-UX) discovers bugs which affect *all* platforms. This is yet one more justification of why it is desirable to write POSIX compatible portable code and check Sage on many platforms. As you can see below, python does not build on my HP C3600 running HP-UX 11i, but we have no clue whatsoever why. Normally Sage would give some clue, but here there is none. python-2.6.2.p4/src/Tools/world/README python-2.6.2.p4/src/Tools/world/world Finished extraction Host system uname -a: HP-UX hpbox B.11.11 U 9000/785 2016698240 unlimited-user license CC Version gcc -v Using built-in specs. Target: hppa1.1-hp-hpux11.11 Configured with: /tmp/gcc-4.3.3.tar.gz/gcc-4.3.3/configure --host=hppa1.1-hp-hpux11.11 --target=hppa1.1-hp-hpux11.11 --build=hppa1.1-hp-hpux11.11 --prefix=/opt/hp-gcc-4.3.3 --with-gnu-as --without-gnu-ld --enable-threads=posix --enable-languages=c,c++ --with-gmp=/proj/opensrc/be/hppa1.1-hp-hpux11.11 --with-mpfr=/proj/opensrc/be/hppa1.1-hp-hpux11.11 Thread model: posix gcc version 4.3.3 (GCC) real0m0.111s user0m0.050s sys 0m0.040s sage: An error occurred while installing python-2.6.2.p4 The reason no error message is generated, is due to the inappropriate use of 'set -e' in the spkg-install script. The package python-2.6.2.p4 has in spkg-install the following code. # This tells Bash to exit the script if any statement returns # a non-true value. set -e # PATCH cp patches/ctypes__init__.py src/Lib/ctypes/__init__.py if [ $? -ne 0 ]; then echo "Error copying patched ctypes" exit 1 fi cp patches/locale.py src/Lib/ if [ $? -ne 0 ]; then echo "Error copying patched locale.py" exit 1 fi It should be noted that 'set -e' causes any failure to result in the script exiting immediately with a non-zero exit code. Since the script has exited, no further processing takes place - even the code which checks for an error! Dave -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] "set -e"
Hi, I just noticed that David Kirkby encouraged us to put "set -e"'s in the Sage spkg-install's, and at the time when I was barely paying attention it seemed like a good idea. So I was just refereeing 6990 and noticed that the spkg-install's are now full of code like this: -- # This tells Bash to exit the script if any statement returns a non-true # value. set -e # PATCH cp patches/ctypes__init__.py src/Lib/ctypes/__init__.py if [ $? -ne 0 ]; then echo "Error copying patched ctypes" exit 1 fi -- Here's the problem. There is *no possible way* the code echo "Error copying patched ctypes" exit 1 will ever get executed! If $? isn't 0, the script already terminated. Thus by adding "set -e" we have made it so every single error message that was carefully written to convey what the problem was is no longer displayed. Sometimes the error messages are fairly obvious from "set -e", as above, but sometimes they aren't at all. Also, some packages, e.g., ratpoints, attempt a build, and if a failure occurs then attempt the same build but with different options. If one were to blithely put "set -a" at the top of such an spkg-install, the result would be to break it on some platforms. This could happen in any number of other situations. So the upshot is that I'm extremely worried about this use of "set -e". It seems good on the surface, but it has some serious hidden costs. William -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---