-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sage -i ...
exits with 0, even if it is unable to install a package.
#9811
Comments
Replying to @sagetrac-drkirkby:
Well, you did A well written command like leif@quadriga:~/Sage/spkgs/mpir-2.1.1$ rm -f non-existent-package ; echo $?
0 I wonder what Sage returns if you do Btw, Hopefully not too many people read our tickets... :D |
This comment has been minimized.
This comment has been minimized.
comment:2
Replying to @nexttime:
The Sage. It still exits with an exit code of zero.
More, should I think. Dave |
comment:3
From ...
install() {
cd "$SAGE_ROOT/spkg"
if [ $# -lt 2 ]; then
sage-spkg
exit $?
fi
OPT="$1"
shift
if [ "$1" = '-m' -o "$1" = '-s' ]; then
OPT=$OPT" "$1
shift
fi
SAGE_LOGS="$SAGE_ROOT/spkg/logs"
if [ ! -d "$SAGE_LOGS" ]; then
mkdir -p "$SAGE_LOGS"
fi
for PKG in "$@"
do
echo "Calling sage-spkg on $PKG"
PKG_NAME=`echo "$PKG" | sed -e "s/\.spkg$//"`
PKG_NAME=`basename "$PKG_NAME"`
case $PKG in
/*)
sage-spkg $OPT "$PKG" 2>&1 | (trap "" SIGINT; tee -a ../install.log "$SAGE_LOGS/$PKG_NAME".log)
;;
*)
sage-spkg $OPT "$CUR/$PKG" 2>&1 | (trap "" SIGINT; tee -a ../install.log "$SAGE_LOGS/$PKG_NAME".log)
;;
esac
if [ $? -ne 0 ]; then
exit 1
fi
shift
done
exit $?
}
...
if [ "$1" = '-i' ]; then
shift
echo "Installing $@"
install " " "$@"
fi
if [ "$1" = '-f' ]; then
shift
echo "Force installing $@"
install -f "$@"
fi
... So once again, we get the exit status of |
This comment has been minimized.
This comment has been minimized.
comment:4
Using |
Author: Leif Leonhardy |
Dependencies: #10157 |
Changed keywords from none to sage-sage return code status pipestatus tee |
comment:7
Attached patch fixes the exit code (by using (I haven't changed more since there are other tickets already touching |
This comment has been minimized.
This comment has been minimized.
sage -i ...
exits with 0, even if it is unable to install a package.
comment:8
CC'ing a potential reviewer... :P |
SCRIPTS repo. Based on Sage 4.7.2.alpha4. |
comment:9
Attachment: trac_9811-use_pipestatus_in_sage-sage.scripts.patch.gz Fixed a typo in a comment. Sorry, patch (diff) doesn't look very nice, as I've changed the indentation (and replaced spaces by tabs). |
Reviewer: John Palmieri |
comment:10
Looks okay to me. |
Merged: sage-4.7.2.rc0 |
I wanted to do some testing of Sage in a loop and would check the return code to see if what I used worked or not. But this is impossible, as Sage appears to exit with 0, even if it should not have. In the example below, I try to install a non-existent package using Sage. The return code in a case like this should be non-zero, but it is not.
The same happens if one uses
sage -i
to install a package. If it fails, the exit code is still 0.In contrast, if I try this with a well written command like
ls
the exit code is non-zero - in this case 2.
Also on a similar theme is #9799, showing that
make
can exit with the wrong code too.Apply
to the Sage scripts repository.
Depends on #10157
CC: @nexttime @qed777 @jhpalmieri
Component: scripts
Keywords: sage-sage return code status pipestatus tee
Author: Leif Leonhardy
Reviewer: John Palmieri
Merged: sage-4.7.2.rc0
Issue created by migration from https://trac.sagemath.org/ticket/9811
The text was updated successfully, but these errors were encountered: