On Thu, Jul 23, 2009 at 2:37 AM, Dr. David
Kirkby<[email protected]> wrote:
>
> William Stein wrote:
>> On Thu, Jul 23, 2009 at 2:18 AM, Dr. David
>> Kirkby<[email protected]> wrote:
>>> William Stein wrote:
>>>> On Thu, Jul 23, 2009 at 1:22 AM, Dr. David
>>>> Kirkby<[email protected]> wrote:
>>>>> I've noticed a couple of issues on Solaris, where it appears packages
>>>>> have been installed properly (the $SAGE_HOME/spkg/installed/foobar is
>>>>> created), but this has not actually happened.
>>>>>
>>>>> On one occasion 'cp -a' was called, which failed to copy files to
>>>>> $SAGE_HOME/local/include, as '-a' is not an option on Solaris to the cp
>>>>> command. Sun's 'cp' reported this as an error, but this did not cause
>>>>> the 'make' to stop.
>>>> After every single command in spkg-install one *must* check the error
>>>> return value.  That's why there is code like the following all over in
>>>> them:
>>>>
>>>> if [ $? -ne 0 ]; then
>>>>     echo "blah went wrong"
>>>>     exit 1
>>>> fi
>>>>
>>>> Anywhere such code doesn't happen is a bug.
>>> Well, there are a lot of bugs then, as a lot of code I see does not
>>> check every command. Checking at the end does not work.
>>>
>>> I just looked at one random package I've never looked at before -
>>> (numpy-1.3.0.p1]
>>>
>>> This contains:
>>>
>>> cp ../patches/gnu.py numpy/distutils/fcompiler/gnu.py
>>> cp ../patches/__init__.py  numpy/distutils/fcompiler/__init__.py
>>>
>>> There are no checks. There is a check later:
>>>
>>> if [ $? -ne 0 ]; then
>>>     echo "Error building numpy."
>>>     exit 1
>>> fi
>>>
>>> but that does not help, as the following script I wrote shows.
>>>
>>> #!/bin/sh
>>> # Try to do something which will fail as non-root
>>>
>>> touch /this-should-fail
>>> pwd
>>> if [ $? -ne 0 ]; then
>>>     echo "This script failed"
>>>     exit 1
>>> fi
>>>
>>> the 'touch' command gives an error, but the message "This script failed"
>>> is *not* printed, as the 'pwd' command later succeeded. If I remove the
>>> 'pwd' command, so it prints the error message.
>>>
>>>
>>>
>>>
>>> Writing
>>>
>>> if [ $? -ne 0 ]; then
>>>     echo "This script failed"
>>>     exit 1
>>> fi
>>>
>>>
>>> after every single command in spkg-install would make the code very long,
>>>
>>
>> Nonetheless, we should be checking the error code after every line
>> executes, one way or another.  Is there a way to automatically do this
>> in bash?
>
> I'm not aware of one, but I'll ask on comp.unix.shell - that is my
> favorite place to ask for this sort of information.
>
> Even if you solve it in spkg-install, it still leaves all the makefiles
> that are used in packages - it is clear to me they don't check that
> their actions have succeeded. If the did, things like a missing
> 'install-sh' would cause it to exit, rather than continue and exit with
> an exit code of 0.
>
> dave

Fortunately you're not right.  If an error is raised by any command in
a makefile, then the make program terminates with an error and exit
code.  As a little test, try this make file:

wst...@boxen:~/tmp$ more makefile
all:
        ls /
        touch /x
        echo "hello"


---

Burcin -- bravo, using "set -e" is a great idea.  This is now trac #6598:

http://trac.sagemath.org/sage_trac/ticket/6598

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to