Ticket #10469: trac_10469-scripts.patch

File trac_10469-scripts.patch, 2.1 KB (added by jhpalmieri, 11 years ago)

scripts repo; replaces other patch

  • sage-env

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1301000020 25200
    # Node ID f524917f47f86bedbc863374585decdc1f405f19
    # Parent  cf7a72f7e93158ef073a0ca3106a211d6df7f492
    #10469: don't source sage-env more than once.
    
    diff -r cf7a72f7e931 -r f524917f47f8 sage-env
    a b  
    1 #!/usr/bin/env bash
     1#!/this/script/must/be/sourced -*- shell-script -*-
    22
    33###########################################################################
    44#
    55#  Set environment variables for building and/or running Sage.
    66#  You must source this; see below!
    7 # 
     7#
    88#  AUTHORS:   William Stein                            2005-12
    99#             David Kirkby <david.kirkby@onetel.net>   2005-12-17
    1010#
     
    1313##########################################################################
    1414#
    1515#  If you want to set all environment variables for your shell like
    16 #  they are during the build of Sage packages, type 
     16#  they are during the build of Sage packages, type
    1717#
    18 #             source local/bin/sage-env 
     18#             source local/bin/sage-env
    1919#
    2020#  from the SAGE_ROOT directory.   To do the same from a /bin/bash
    21 #  script use ". local/bin/sage-env". 
    22 # 
     21#  script use ". local/bin/sage-env".
     22#
    2323##########################################################################
    2424
    2525# GUESS SAGE_ROOT from pwd
    if [ "$SAGE_ROOT" = "" ]; then 
    4545        exit 1
    4646    else
    4747        SAGE_ROOT="$GUESSED_SAGE_ROOT"
    48         export SAGE_ROOT
     48        EXPORT_SAGE_ROOT="yes"
    4949    fi
    5050else
    5151    if [ -f "$SAGE_ROOT"/sage -a -d "$SAGE_ROOT"/spkg ]; then
    else 
    6262    fi
    6363fi
    6464
     65# Don't execute the commands more than once.  Check this after
     66# checking the validity of SAGE_ROOT, but before modifying its value.
     67if [ "x$SAGE_ENV_SOURCED" = "x" ]; then
     68    SAGE_ENV_SOURCED=1
     69    export SAGE_ENV_SOURCED
     70else
     71    # Already sourced, nothing to do.
     72    return 0
     73fi
     74
     75if [ "$EXPORT_SAGE_ROOT" = "yes" ]; then
     76    export SAGE_ROOT
     77fi
    6578
    6679# Call with: contains_spaces X${VAR}X
    6780# i.e., WITHOUT quotes but some character(s) around the environment variable to test.