Skip to content

Commit 6e50ba9

Browse files
author
Matthias Koeppe
committed
src/bin/sage: Handle -b... options before sourcing sage-env
1 parent a6ba630 commit 6e50ba9

File tree

1 file changed

+32
-40
lines changed

1 file changed

+32
-40
lines changed

src/bin/sage

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ if [ "$1" = '-patchbot' -o "$1" = "--patchbot" ]; then
216216
exit 127
217217
fi
218218

219+
# build_sage, sage -b, sage -br, etc. could also be moved to
220+
# build/bin/sage-site. See #29111; but OTOH #34627.
221+
222+
build_sage() {
223+
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
224+
}
225+
219226
# Check for '-i' etc. before sourcing sage-env: running "make"
220227
# should be run outside of the Sage shell.
221228
case "$1" in
@@ -229,6 +236,28 @@ case "$1" in
229236
echo >&2 "Error: unknown option: $1"
230237
exit 1
231238
;;
239+
-b)
240+
build_sage
241+
exit 0
242+
;;
243+
-br|--br)
244+
build_sage
245+
shift; set -- -r "$@" # delegate to handling of "-r" below, after sourcing sage-env
246+
;;
247+
-bn|--build-and-notebook)
248+
build_sage
249+
shift; set -- -n "$@" # delegate to handling of "-n" below, after sourcing sage-env
250+
;;
251+
-ba)
252+
( cd "$SAGE_ROOT" && make sagelib-clean )
253+
build_sage
254+
exit 0
255+
;;
256+
-bt*)
257+
build_sage
258+
switch_without_b=-${1#-b}
259+
shift; set -- $switch_without_b "$@" # delegate to handling of "-t...." below, after sourcing sage-env
260+
;;
232261
esac
233262

234263
#####################################################################
@@ -865,12 +894,6 @@ fi
865894
# The notebook, grep, building Sage, testing Sage
866895
#####################################################################
867896

868-
# build_sage, sage -b, sage -br, etc. could be moved to
869-
# build/bin/sage-site. See #29111.
870-
871-
build_sage() {
872-
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
873-
}
874897

875898
if [[ "$1" =~ ^--notebook=.* || "$1" =~ ^-n=.* || "$1" =~ ^-notebook=.* ]] ; then
876899
sage-cleaner &>/dev/null &
@@ -905,47 +928,19 @@ if [ -n "$SAGE_SRC" -a -d "$SAGE_SRC" ]; then
905928
fi
906929
fi
907930

908-
if [ "$1" = '-b' ]; then
909-
build_sage
910-
exit $?
911-
fi
912-
913-
if [ "$1" = '-br' -o "$1" = "--br" ]; then
914-
build_sage
915-
interactive_sage
916-
fi
917-
918931
if [ "$1" = '-r' ]; then
919932
shift
920933
interactive_sage
921934
fi
922935

923-
if [ "$1" = '-ba-force' -o "$1" = '--ba-force' ]; then
924-
echo
925-
echo "WARNING: 'sage --ba-force' is deprecated; use 'sage -ba' instead."
926-
echo
927-
( cd "$SAGE_ROOT" && make sagelib-clean )
928-
build_sage
929-
exit $?
930-
fi
931-
932-
if [ "$1" = '-ba' ]; then
933-
( cd "$SAGE_ROOT" && make sagelib-clean )
934-
build_sage
935-
exit $?
936-
fi
937-
938936
exec-runtests() {
939937
sage_setup
940938
export PYTHONIOENCODING="utf-8" # Fix encoding for doctests
941939
exec sage-runtests "$@"
942940
}
943941

944-
if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" = '-tp' -o "$1" = '-btp' ]; then
945-
if [ "$1" = '-bt' -o "$1" = '-btp' ]; then
946-
build_sage
947-
fi
948-
if [ "$1" = '-tp' -o "$1" = '-btp' ]; then
942+
if [ "$1" = '-t' -o "$1" = '-tp' ]; then
943+
if [ "$1" = '-tp' ]; then
949944
shift
950945
exec-runtests -p "$@"
951946
else
@@ -954,10 +949,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" = '-tp' -o "$1" = '-btp' ]; then
954949
fi
955950
fi
956951

957-
if [ "$1" = '-tnew' -o "$1" = '-btnew' ]; then
958-
if [ "$1" = '-btnew' ]; then
959-
build_sage
960-
fi
952+
if [ "$1" = '-tnew' ]; then
961953
shift
962954
exec-runtests --new "$@"
963955
fi

0 commit comments

Comments
 (0)