# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1347821984 -7200
# Node ID 4f0a8f4f37f9bfb93148368b27285da248c3c745
# Parent be1a4a34155d33814ccb6a958db8f18e43b38ba5
spkg/bin/sage: do not change directory
diff --git a/spkg/bin/sage b/spkg/bin/sage
a
|
b
|
|
235 | 235 | exit 0 |
236 | 236 | } |
237 | 237 | |
238 | | # Save the current directory, so we can change back after startup |
239 | | # If pwd fails, we fall back to SAGE_ROOT |
240 | | CUR=`pwd` || CUR="$SAGE_ROOT" |
241 | | export CUR |
242 | | |
243 | | cd "$SAGE_ROOT" |
244 | | |
245 | 238 | # Check for '--nodotsage' before sourcing sage-env; otherwise sage-env |
246 | 239 | # will already have set some environment variables with the old |
247 | 240 | # setting for DOT_SAGE. |
… |
… |
|
256 | 249 | |
257 | 250 | # Do NOT redirect stderr and stdout to /dev/null, |
258 | 251 | # since sage-env might print important error messages: |
259 | | . spkg/bin/sage-env |
| 252 | . "$SAGE_ROOT/spkg/bin/sage-env" |
260 | 253 | if [ $? -ne 0 ]; then |
261 | 254 | echo >&2 "Error setting environment variables by sourcing '$SAGE_ROOT/spkg/bin/sage-env';" |
262 | 255 | echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)." |
… |
… |
|
294 | 287 | |
295 | 288 | # Check to see if the whole Sage install tree has moved. |
296 | 289 | # If so, change various hardcoded paths. |
297 | | "$SAGE_ROOT/local/bin/"sage-location |
298 | | if [ $? -ne 0 ]; then |
299 | | exit 1 |
300 | | fi |
| 290 | sage-location || exit $? |
301 | 291 | |
302 | | cd "$SAGE_ROOT/local/bin" |
303 | | IPYTHONDIR="$DOT_SAGE/ipython" && export IPYTHONDIR |
304 | | IPYTHONRC="ipythonrc" && export IPYTHONRC |
| 292 | export IPYTHONDIR="$DOT_SAGE/ipython" |
| 293 | export IPYTHONRC="ipythonrc" |
305 | 294 | if [ ! -d "$IPYTHONDIR" ]; then |
306 | 295 | mkdir -p "$DOT_SAGE" |
307 | 296 | cp -r "$SAGE_ROOT/ipython" "$DOT_SAGE/" |
… |
… |
|
310 | 299 | } |
311 | 300 | |
312 | 301 | |
313 | | # Below the command |
314 | | # _=sage.misc.interpreter.do_prefilter_paste('',False) |
315 | | |
316 | | # It is very important in the following assignments |
317 | | # that there is no whitespace after the backslashes. |
318 | | |
319 | | ######################################################## |
320 | | # Regarding printing the branch below: |
321 | | # We print a message with the library branch that |
322 | | # Sage is currently being run from. If they are using |
323 | | # main branch, we print nothing, otherwise users get |
324 | | # very confused about what branch they are using. |
325 | | ######################################################## |
326 | | |
327 | | |
328 | | |
329 | 302 | if [ $# -gt 0 ]; then |
330 | 303 | if [ "$1" = "-np" ]; then |
331 | 304 | LOGOPT="-prompt_out=\\r $LOGOPT" |
… |
… |
|
371 | 344 | fi |
372 | 345 | |
373 | 346 | if [ "$1" = '-branch' -o "$1" = '--branch' ]; then |
374 | | cd "$SAGE_ROOT/devel/sage" && pwd -P | sed 's|.*/||; s|^sage-||' |
| 347 | cd "$SAGE_ROOT/devel/sage" |
| 348 | pwd -P | sed 's|.*/||; s|^sage-||' |
375 | 349 | exit $? |
376 | 350 | fi |
377 | 351 | |
… |
… |
|
380 | 354 | ##################################################################### |
381 | 355 | |
382 | 356 | if [ "$1" = '-axiom' -o "$1" = '--axiom' ]; then |
383 | | cd "$CUR" |
384 | 357 | shift |
385 | 358 | axiom "$@" |
386 | 359 | exit $? |
387 | 360 | fi |
388 | 361 | |
389 | 362 | if [ "$1" = '-combinat' -o "$1" = '--combinat' ]; then |
390 | | cd "$CUR" |
391 | 363 | shift |
392 | 364 | sage-combinat "$@" |
393 | 365 | exit $? |
394 | 366 | fi |
395 | 367 | |
396 | 368 | if [ "$1" = '-gap' -o "$1" = '--gap' ]; then |
397 | | cd "$CUR" |
398 | 369 | shift |
399 | 370 | "$SAGE_LOCAL/bin/gap" "$@" |
400 | 371 | exit $? |
401 | 372 | fi |
402 | 373 | |
403 | 374 | if [ "$1" = '-gp' -o "$1" = '--gp' ]; then |
404 | | cd "$CUR" |
405 | 375 | shift |
406 | 376 | "$SAGE_LOCAL/bin/gp" "$@" |
407 | 377 | exit $? |
408 | 378 | fi |
409 | 379 | |
410 | 380 | if [ "$1" = '-singular' -o "$1" = '--singular' ]; then |
411 | | cd "$CUR" |
412 | 381 | shift |
413 | 382 | "$SAGE_LOCAL/bin/singular" "$@" |
414 | 383 | exit $? |
415 | 384 | fi |
416 | 385 | |
417 | 386 | if [ "$1" = '-sqlite3' -o "$1" = '--sqlite3' ]; then |
418 | | cd "$CUR" |
419 | 387 | shift |
420 | 388 | "$SAGE_LOCAL/bin/sqlite3" "$@" |
421 | 389 | exit $? |
422 | 390 | fi |
423 | 391 | |
424 | 392 | if [ "$1" = '-twistd' -o "$1" = '--twistd' ]; then |
425 | | cd "$CUR" |
426 | 393 | shift |
427 | 394 | python $(which twistd) "$@" |
428 | 395 | exit $? |
429 | 396 | fi |
430 | 397 | |
431 | 398 | if [ "$1" = '-ecl' -o "$1" = '--ecl' ]; then |
432 | | cd "$CUR" |
433 | 399 | shift |
434 | 400 | "$SAGE_LOCAL/bin/ecl" "$@" |
435 | 401 | exit $? |
436 | 402 | fi |
437 | 403 | |
438 | 404 | if [ "$1" = '-lisp' -o "$1" = '--lisp' ]; then |
439 | | cd "$CUR" |
440 | 405 | shift |
441 | 406 | "$SAGE_LOCAL/bin/ecl" "$@" |
442 | 407 | exit $? |
443 | 408 | fi |
444 | 409 | |
445 | 410 | if [ "$1" = '-kash' -o "$1" = '--kash' ]; then |
446 | | cd "$CUR" |
447 | 411 | shift |
448 | 412 | "$SAGE_LOCAL/bin/kash" "$@" |
449 | 413 | exit $? |
450 | 414 | fi |
451 | 415 | |
452 | 416 | if [ "$1" = '-fixdoctests' -o "$1" = '--fixdoctests' ]; then |
453 | | cd "$CUR" |
454 | 417 | shift |
455 | 418 | sage-fixdoctests "$@" |
456 | 419 | exit $? |
457 | 420 | fi |
458 | 421 | |
459 | 422 | if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then |
460 | | cd "$CUR" |
461 | 423 | shift |
462 | 424 | "$SAGE_LOCAL/bin/maxima" "$@" |
463 | 425 | exit $? |
464 | 426 | fi |
465 | 427 | |
466 | 428 | if [ "$1" = '-mwrank' -o "$1" = '--mwrank' ]; then |
467 | | cd "$CUR" |
468 | 429 | shift |
469 | 430 | "$SAGE_LOCAL/bin/mwrank" "$@" |
470 | 431 | exit $? |
471 | 432 | fi |
472 | 433 | |
473 | 434 | if [ "$1" = '-M2' -o "$1" = '--M2' ]; then |
474 | | cd "$CUR" |
475 | 435 | shift |
476 | 436 | "$SAGE_LOCAL/bin/M2" "$@" |
477 | 437 | exit $? |
478 | 438 | fi |
479 | 439 | |
480 | 440 | if [ "$1" = '-scons' -o "$1" = '--scons' ]; then |
481 | | cd "$CUR" |
482 | 441 | shift |
483 | 442 | "$SAGE_LOCAL/bin/scons" "$@" |
484 | 443 | exit $? |
485 | 444 | fi |
486 | 445 | |
487 | 446 | if [ "$1" = '-python' -o "$1" = '--python' ]; then |
488 | | cd "$CUR" |
489 | 447 | shift |
490 | 448 | python "$@" |
491 | 449 | exit $? |
492 | 450 | fi |
493 | 451 | |
494 | 452 | if [ "$1" = '-R' -o "$1" = '--R' ]; then |
495 | | cd "$CUR" |
496 | 453 | shift |
497 | 454 | "$SAGE_LOCAL/bin/R" "$@" |
498 | 455 | exit $? |
499 | 456 | fi |
500 | 457 | |
501 | 458 | if [ "$1" = '-ipython' -o "$1" = '--ipython' ]; then |
502 | | cd "$CUR" |
503 | 459 | shift |
504 | 460 | "$SAGE_LOCAL/bin/ipython" "$@" |
505 | 461 | exit $? |
… |
… |
|
512 | 468 | # - Martin Albrecht: fix zshell prompt (#11866) |
513 | 469 | # - John Palmieri: shorten the prompts, and don't print messages if |
514 | 470 | # there are more arguments to 'sage -sh' (#11790) |
515 | | cd "$CUR" |
516 | 471 | shift |
517 | 472 | # If $SHELL is unset, default to bash |
518 | 473 | if [ -z "$SHELL" ]; then |
… |
… |
|
625 | 580 | fi |
626 | 581 | |
627 | 582 | if [ "$1" = '-gdb-ipython' -o "$1" = '--gdb-ipython' ]; then |
628 | | cd "$CUR" |
629 | 583 | shift |
630 | 584 | sage-gdb-ipython "$@" |
631 | 585 | exit $? |
632 | 586 | fi |
633 | 587 | |
634 | 588 | if [ "$1" = '-hg' -o "$1" = '--hg' ]; then |
635 | | cd "$CUR" |
636 | 589 | shift |
637 | 590 | # Disable HGPLAIN, so we use all user defaults |
638 | 591 | # (both in $SAGE_LOCAL/etc/mercurial and $HOME/.hgrc) |
… |
… |
|
642 | 595 | fi |
643 | 596 | |
644 | 597 | if [ "$1" = '-merge' ]; then |
645 | | cd "$CUR" |
646 | 598 | shift |
647 | 599 | sage-apply-ticket "$@" |
648 | 600 | exit $? |
… |
… |
|
653 | 605 | ##################################################################### |
654 | 606 | |
655 | 607 | if [ "$1" = "-coverage" -o "$1" = "--coverage" ]; then |
656 | | cd "$CUR" |
657 | 608 | shift |
658 | 609 | sage-coverage "$@" |
659 | 610 | exit $? |
660 | 611 | fi |
661 | 612 | |
662 | 613 | if [ "$1" = "-coverageall" -o "$1" = "--coverageall" ]; then |
663 | | cd "$CUR" |
664 | 614 | shift |
665 | 615 | sage-coverageall "$@" |
666 | 616 | exit $? |
… |
… |
|
671 | 621 | ##################################################################### |
672 | 622 | |
673 | 623 | if [ "$1" = '-rst2txt' -o "$1" = '--rst2txt' ]; then |
674 | | cd "$CUR" |
675 | 624 | shift |
676 | 625 | sage-rst2txt "$@" |
677 | 626 | exit $? |
678 | 627 | fi |
679 | 628 | |
680 | 629 | if [ "$1" = '-rst2sws' -o "$1" = '--rst2sws' ]; then |
681 | | cd "$CUR" |
682 | 630 | shift |
683 | 631 | sage-rst2sws "$@" |
684 | 632 | exit $? |
… |
… |
|
690 | 638 | |
691 | 639 | if [ "$1" = "-crap" -o "$1" = "--crap" ]; then |
692 | 640 | shift |
693 | | cd "$CUR" |
694 | 641 | sage-crap $@ |
695 | 642 | exit $? |
696 | 643 | fi |
… |
… |
|
704 | 651 | } |
705 | 652 | |
706 | 653 | if [ "$1" = "-notebook" -o "$1" = '--notebook' -o "$1" = '-n' ]; then |
707 | | cd "$CUR" |
708 | 654 | shift |
709 | 655 | sage-cleaner &>/dev/null & |
710 | 656 | sage-notebook "$@" |
… |
… |
|
712 | 658 | fi |
713 | 659 | |
714 | 660 | if [ "$1" = "-bn" -o "$1" = "--build-and-notebook" ]; then |
715 | | cd "$CUR" |
716 | 661 | shift |
717 | 662 | sage-cleaner &>/dev/null & |
718 | 663 | build_sage |
… |
… |
|
721 | 666 | fi |
722 | 667 | |
723 | 668 | if [ "$1" = "-inotebook" -o "$1" = '--inotebook' ]; then |
724 | | cd "$CUR" |
725 | 669 | shift |
726 | 670 | sage-cleaner &>/dev/null & |
727 | 671 | sage-notebook-insecure "$@" |
… |
… |
|
786 | 730 | # remove the correct file. |
787 | 731 | rm -f "$SAGE_ROOT/devel/sage" |
788 | 732 | ln -s "sage-$1" sage |
789 | | cd "$SAGE_ROOT" |
790 | 733 | fi |
791 | 734 | sage |
792 | 735 | exit $? |
… |
… |
|
819 | 762 | |
820 | 763 | if [ "$1" = '-sync-build' -o "$1" = '--sync-build' ]; then |
821 | 764 | shift |
| 765 | cd "$SAGE_ROOT" |
822 | 766 | python "$SAGE_LOCAL"/bin/sage-sync-build.py "$@" |
823 | 767 | exit $? |
824 | 768 | fi |
… |
… |
|
837 | 781 | echo >&2 "init.sage does not exist ... creating" |
838 | 782 | touch "$DOT_SAGE"/init.sage |
839 | 783 | fi |
840 | | cd "$CUR" |
841 | 784 | shift |
842 | 785 | sage-test "$@" |
843 | 786 | exit $? |
… |
… |
|
851 | 794 | echo >&2 "init.sage does not exist ... creating" |
852 | 795 | touch "$DOT_SAGE"/init.sage |
853 | 796 | fi |
854 | | cd "$CUR" |
855 | 797 | shift |
856 | 798 | sage-ptest "$@" |
857 | 799 | exit $? |
… |
… |
|
861 | 803 | if [ "$1" = '-btnew' ]; then |
862 | 804 | build_sage |
863 | 805 | fi |
864 | | cd "$CUR" |
865 | 806 | shift |
866 | 807 | sage-test-new "$@" |
867 | 808 | exit $? |
… |
… |
|
875 | 816 | |
876 | 817 | if [ "$1" = '-patchbot' -o "$1" = "--patchbot" ]; then |
877 | 818 | shift |
| 819 | cd "$SAGE_ROOT" |
878 | 820 | "$SAGE_LOCAL/bin/patchbot/patchbot.py" "$@" |
879 | 821 | exit $? |
880 | 822 | fi |
881 | 823 | |
882 | 824 | if [ "$1" = '-c' ]; then |
883 | | cd "$CUR" |
884 | 825 | shift |
885 | 826 | SAGE_BANNER="no" |
886 | 827 | sage_setup |
… |
… |
|
890 | 831 | fi |
891 | 832 | |
892 | 833 | install() { |
893 | | cd "$CUR" |
894 | 834 | mkdir -p "$SAGE_LOGS" |
895 | 835 | for PKG in "$@" |
896 | 836 | do |
… |
… |
|
975 | 915 | fi |
976 | 916 | |
977 | 917 | if [ "$1" = '-pkg' -o "$1" = '-spkg' -o "$1" = "--pkg" -o "$1" = "--spkg" ]; then |
978 | | cd "$CUR" |
979 | 918 | shift |
980 | 919 | sage-pkg "$@" |
981 | 920 | exit $? |
982 | 921 | fi |
983 | 922 | |
984 | 923 | if [ "$1" = '-pkg_nc' -o "$1" = "--pkg_nc" ]; then |
985 | | cd "$CUR" |
986 | 924 | shift |
987 | 925 | sage-pkg -n "$@" |
988 | 926 | exit $? |
… |
… |
|
1011 | 949 | echo >&2 "** MISSING VERSION NUMBER! **" |
1012 | 950 | exit 1 |
1013 | 951 | fi |
| 952 | cd "$SAGE_ROOT" |
1014 | 953 | sage-bdist $2 "$SAGE_ROOT" |
1015 | 954 | exit $? |
1016 | 955 | fi |
… |
… |
|
1028 | 967 | |
1029 | 968 | if [ "$1" = '-upgrade' -o "$1" = "--upgrade" ]; then |
1030 | 969 | shift |
| 970 | cd "$SAGE_ROOT" |
1031 | 971 | |
1032 | 972 | # People often move the Sage install right before doing the upgrade, so it's |
1033 | 973 | # important to fix any path hardcoding issues first, or certain library |
… |
… |
|
1050 | 990 | fi |
1051 | 991 | |
1052 | 992 | if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then |
1053 | | cd "$CUR" |
1054 | 993 | shift |
1055 | 994 | python "$SAGE_ROOT"/devel/sage/doc/common/builder.py $@ |
1056 | 995 | exit $? |
… |
… |
|
1065 | 1004 | |
1066 | 1005 | if [ "$1" = '-preparse' -o "$1" = "--preparse" ]; then |
1067 | 1006 | shift |
1068 | | cd "$SAGE_LOCAL/bin/" |
1069 | | sage-preparse "$CUR" "$@" |
| 1007 | sage-preparse "$@" |
1070 | 1008 | exit $? |
1071 | 1009 | fi |
1072 | 1010 | |
1073 | 1011 | if [ "$1" = "-cython" -o "$1" = '--cython' -o "$1" = '-pyrex' -o "$1" = "--pyrex" ]; then |
1074 | 1012 | shift |
1075 | | cd "$CUR" |
1076 | 1013 | sage-cython "$@" |
1077 | 1014 | exit $? |
1078 | 1015 | fi |
… |
… |
|
1121 | 1058 | if [ "$T" = "spkg" ]; then |
1122 | 1059 | install "$@" |
1123 | 1060 | fi |
1124 | | cd "$SAGE_LOCAL/bin/" |
1125 | 1061 | SAGE_BANNER="no" |
1126 | 1062 | sage_setup |
1127 | 1063 | unset TERM # See Trac #12263 |
1128 | | sage-run "$CUR" "$@" |
| 1064 | sage-run "$@" |
1129 | 1065 | exit $? |
1130 | 1066 | fi |