Ticket #13459: 13459_no_cd.patch

File 13459_no_cd.patch, 9.5 KB (added by jdemeyer, 9 years ago)
  • spkg/bin/sage

    # 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  
    235235    exit 0
    236236}
    237237
    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 
    245238# Check for '--nodotsage' before sourcing sage-env; otherwise sage-env
    246239# will already have set some environment variables with the old
    247240# setting for DOT_SAGE.
     
    256249
    257250# Do NOT redirect stderr and stdout to /dev/null,
    258251# since sage-env might print important error messages:
    259 . spkg/bin/sage-env
     252. "$SAGE_ROOT/spkg/bin/sage-env"
    260253if [ $? -ne 0 ]; then
    261254   echo >&2 "Error setting environment variables by sourcing '$SAGE_ROOT/spkg/bin/sage-env';"
    262255   echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
     
    294287
    295288    # Check to see if the whole Sage install tree has moved.
    296289    # 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 $?
    301291
    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"
    305294    if [ ! -d "$IPYTHONDIR" ]; then
    306295        mkdir -p "$DOT_SAGE"
    307296        cp -r "$SAGE_ROOT/ipython" "$DOT_SAGE/"
     
    310299}
    311300
    312301
    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 
    329302if [ $# -gt 0 ]; then
    330303    if [ "$1" = "-np" ]; then
    331304       LOGOPT="-prompt_out=\\r $LOGOPT"
     
    371344fi
    372345
    373346if [ "$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-||'
    375349    exit $?
    376350fi
    377351
     
    380354#####################################################################
    381355
    382356if [ "$1" = '-axiom' -o "$1" = '--axiom' ]; then
    383     cd "$CUR"
    384357    shift
    385358    axiom "$@"
    386359    exit $?
    387360fi
    388361
    389362if [ "$1" = '-combinat' -o "$1" = '--combinat' ]; then
    390     cd "$CUR"
    391363    shift
    392364    sage-combinat "$@"
    393365    exit $?
    394366fi
    395367
    396368if [ "$1" = '-gap' -o "$1" = '--gap' ]; then
    397     cd "$CUR"
    398369    shift
    399370    "$SAGE_LOCAL/bin/gap" "$@"
    400371    exit $?
    401372fi
    402373
    403374if [ "$1" = '-gp'  -o "$1" = '--gp' ]; then
    404     cd "$CUR"
    405375    shift
    406376    "$SAGE_LOCAL/bin/gp" "$@"
    407377    exit $?
    408378fi
    409379
    410380if [ "$1" = '-singular'  -o "$1" = '--singular' ]; then
    411     cd "$CUR"
    412381    shift
    413382    "$SAGE_LOCAL/bin/singular" "$@"
    414383    exit $?
    415384fi
    416385
    417386if [ "$1" = '-sqlite3'  -o "$1" = '--sqlite3' ]; then
    418     cd "$CUR"
    419387    shift
    420388    "$SAGE_LOCAL/bin/sqlite3" "$@"
    421389    exit $?
    422390fi
    423391
    424392if [ "$1" = '-twistd'  -o "$1" = '--twistd' ]; then
    425     cd "$CUR"
    426393    shift
    427394    python $(which twistd) "$@"
    428395    exit $?
    429396fi
    430397
    431398if [ "$1" = '-ecl'  -o "$1" = '--ecl' ]; then
    432     cd "$CUR"
    433399    shift
    434400    "$SAGE_LOCAL/bin/ecl" "$@"
    435401    exit $?
    436402fi
    437403
    438404if [ "$1" = '-lisp'  -o "$1" = '--lisp' ]; then
    439     cd "$CUR"
    440405    shift
    441406    "$SAGE_LOCAL/bin/ecl" "$@"
    442407    exit $?
    443408fi
    444409
    445410if [ "$1" = '-kash'  -o "$1" = '--kash' ]; then
    446     cd "$CUR"
    447411    shift
    448412    "$SAGE_LOCAL/bin/kash" "$@"
    449413    exit $?
    450414fi
    451415
    452416if [ "$1" = '-fixdoctests' -o "$1" = '--fixdoctests' ]; then
    453     cd "$CUR"
    454417    shift
    455418    sage-fixdoctests "$@"
    456419    exit $?
    457420fi
    458421
    459422if [ "$1" = '-maxima'  -o "$1" = '--maxima' ]; then
    460     cd "$CUR"
    461423    shift
    462424    "$SAGE_LOCAL/bin/maxima" "$@"
    463425    exit $?
    464426fi
    465427
    466428if [ "$1" = '-mwrank'  -o "$1" = '--mwrank' ]; then
    467     cd "$CUR"
    468429    shift
    469430    "$SAGE_LOCAL/bin/mwrank" "$@"
    470431    exit $?
    471432fi
    472433
    473434if [ "$1" = '-M2'  -o "$1" = '--M2' ]; then
    474     cd "$CUR"
    475435    shift
    476436    "$SAGE_LOCAL/bin/M2" "$@"
    477437    exit $?
    478438fi
    479439
    480440if [ "$1" = '-scons'  -o "$1" = '--scons' ]; then
    481     cd "$CUR"
    482441    shift
    483442    "$SAGE_LOCAL/bin/scons" "$@"
    484443    exit $?
    485444fi
    486445
    487446if [ "$1" = '-python'  -o "$1" = '--python' ]; then
    488     cd "$CUR"
    489447    shift
    490448    python "$@"
    491449    exit $?
    492450fi
    493451
    494452if [ "$1" = '-R'  -o "$1" = '--R' ]; then
    495     cd "$CUR"
    496453    shift
    497454    "$SAGE_LOCAL/bin/R" "$@"
    498455    exit $?
    499456fi
    500457
    501458if [ "$1" = '-ipython'  -o "$1" = '--ipython' ]; then
    502     cd "$CUR"
    503459    shift
    504460    "$SAGE_LOCAL/bin/ipython" "$@"
    505461    exit $?
     
    512468    # - Martin Albrecht: fix zshell prompt (#11866)
    513469    # - John Palmieri: shorten the prompts, and don't print messages if
    514470    #   there are more arguments to 'sage -sh' (#11790)
    515     cd "$CUR"
    516471    shift
    517472    # If $SHELL is unset, default to bash
    518473    if [ -z "$SHELL" ]; then
     
    625580fi
    626581
    627582if [ "$1" = '-gdb-ipython'  -o "$1" = '--gdb-ipython' ]; then
    628     cd "$CUR"
    629583    shift
    630584    sage-gdb-ipython "$@"
    631585    exit $?
    632586fi
    633587
    634588if [ "$1" = '-hg'  -o "$1" = '--hg' ]; then
    635     cd "$CUR"
    636589    shift
    637590    # Disable HGPLAIN, so we use all user defaults
    638591    # (both in $SAGE_LOCAL/etc/mercurial and $HOME/.hgrc)
     
    642595fi
    643596
    644597if [ "$1" = '-merge' ]; then
    645     cd "$CUR"
    646598    shift
    647599    sage-apply-ticket "$@"
    648600    exit $?
     
    653605#####################################################################
    654606
    655607if [ "$1" = "-coverage" -o "$1" = "--coverage" ]; then
    656    cd "$CUR"
    657608   shift
    658609   sage-coverage "$@"
    659610   exit $?
    660611fi
    661612
    662613if [ "$1" = "-coverageall" -o "$1" = "--coverageall" ]; then
    663    cd "$CUR"
    664614   shift
    665615   sage-coverageall "$@"
    666616   exit $?
     
    671621#####################################################################
    672622
    673623if [ "$1" = '-rst2txt' -o "$1" = '--rst2txt' ]; then
    674     cd "$CUR"
    675624    shift
    676625    sage-rst2txt "$@"
    677626    exit $?
    678627fi
    679628
    680629if [ "$1" = '-rst2sws' -o "$1" = '--rst2sws' ]; then
    681     cd "$CUR"
    682630    shift
    683631    sage-rst2sws "$@"
    684632    exit $?
     
    690638
    691639if [ "$1" = "-crap" -o "$1" = "--crap" ]; then
    692640   shift
    693    cd "$CUR"
    694641   sage-crap $@
    695642   exit $?
    696643fi
     
    704651}
    705652
    706653if [ "$1" = "-notebook"  -o "$1" = '--notebook' -o "$1" = '-n' ]; then
    707    cd "$CUR"
    708654   shift
    709655   sage-cleaner &>/dev/null &
    710656   sage-notebook "$@"
     
    712658fi
    713659
    714660if [ "$1" = "-bn" -o "$1" = "--build-and-notebook" ]; then
    715     cd "$CUR"
    716661    shift
    717662    sage-cleaner &>/dev/null &
    718663    build_sage
     
    721666fi
    722667
    723668if [ "$1" = "-inotebook"  -o "$1" = '--inotebook' ]; then
    724    cd "$CUR"
    725669   shift
    726670   sage-cleaner &>/dev/null &
    727671   sage-notebook-insecure "$@"
     
    786730      # remove the correct file.
    787731      rm -f "$SAGE_ROOT/devel/sage"
    788732      ln -s "sage-$1" sage
    789       cd "$SAGE_ROOT"
    790733   fi
    791734   sage
    792735   exit $?
     
    819762
    820763if [ "$1" = '-sync-build' -o "$1" = '--sync-build' ]; then
    821764   shift
     765   cd "$SAGE_ROOT"
    822766   python "$SAGE_LOCAL"/bin/sage-sync-build.py "$@"
    823767   exit $?
    824768fi
     
    837781      echo >&2 "init.sage does not exist ... creating"
    838782      touch "$DOT_SAGE"/init.sage
    839783   fi
    840    cd "$CUR"
    841784   shift
    842785   sage-test "$@"
    843786   exit $?
     
    851794      echo >&2 "init.sage does not exist ... creating"
    852795      touch "$DOT_SAGE"/init.sage
    853796   fi
    854    cd "$CUR"
    855797   shift
    856798   sage-ptest "$@"
    857799   exit $?
     
    861803   if [ "$1" = '-btnew' ]; then
    862804      build_sage
    863805   fi
    864    cd "$CUR"
    865806   shift
    866807   sage-test-new "$@"
    867808   exit $?
     
    875816
    876817if [ "$1" = '-patchbot' -o "$1" = "--patchbot" ]; then
    877818   shift
     819   cd "$SAGE_ROOT"
    878820   "$SAGE_LOCAL/bin/patchbot/patchbot.py" "$@"
    879821   exit $?
    880822fi
    881823
    882824if [ "$1" = '-c' ]; then
    883    cd "$CUR"
    884825   shift
    885826   SAGE_BANNER="no"
    886827   sage_setup
     
    890831fi
    891832
    892833install() {
    893     cd "$CUR"
    894834    mkdir -p "$SAGE_LOGS"
    895835    for PKG in "$@"
    896836    do
     
    975915fi
    976916
    977917if [ "$1" = '-pkg' -o "$1" = '-spkg' -o "$1" = "--pkg" -o "$1" = "--spkg" ]; then
    978    cd "$CUR"
    979918   shift
    980919   sage-pkg "$@"
    981920   exit $?
    982921fi
    983922
    984923if [ "$1" = '-pkg_nc' -o "$1" = "--pkg_nc" ]; then
    985    cd "$CUR"
    986924   shift
    987925   sage-pkg -n "$@"
    988926   exit $?
     
    1011949       echo >&2 "** MISSING VERSION NUMBER! **"
    1012950       exit 1
    1013951   fi
     952   cd "$SAGE_ROOT"
    1014953   sage-bdist $2 "$SAGE_ROOT"
    1015954   exit $?
    1016955fi
     
    1028967
    1029968if [ "$1" = '-upgrade' -o "$1" = "--upgrade" ]; then
    1030969    shift
     970    cd "$SAGE_ROOT"
    1031971
    1032972    # People often move the Sage install right before doing the upgrade, so it's
    1033973    # important to fix any path hardcoding issues first, or certain library
     
    1050990fi
    1051991
    1052992if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
    1053    cd "$CUR"
    1054993   shift
    1055994   python "$SAGE_ROOT"/devel/sage/doc/common/builder.py $@
    1056995   exit $?
     
    10651004
    10661005if [ "$1" = '-preparse' -o "$1" = "--preparse" ]; then
    10671006    shift
    1068     cd "$SAGE_LOCAL/bin/"
    1069     sage-preparse "$CUR" "$@"
     1007    sage-preparse "$@"
    10701008    exit $?
    10711009fi
    10721010
    10731011if [ "$1" = "-cython" -o "$1" = '--cython' -o "$1" = '-pyrex' -o "$1" = "--pyrex" ]; then
    10741012    shift
    1075     cd "$CUR"
    10761013    sage-cython "$@"
    10771014    exit $?
    10781015fi
     
    11211058   if [ "$T" = "spkg" ]; then
    11221059       install "$@"
    11231060   fi
    1124    cd "$SAGE_LOCAL/bin/"
    11251061   SAGE_BANNER="no"
    11261062   sage_setup
    11271063   unset TERM  # See Trac #12263
    1128    sage-run "$CUR" "$@"
     1064   sage-run "$@"
    11291065   exit $?
    11301066fi