Ticket #10469: trac_10469.v3.patch

File trac_10469.v3.patch, 2.1 KB (added by kini, 11 years ago)
  • sage-env

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1301011752 25200
    # Node ID 91b899d0959459996c59eabbd516551af2ee0379
    # Parent  f3e8fdd3002e03b0a809fb4bc14f0138d375f5a7
    #10469: don't source sage-env more than once.
    
    diff --git a/sage-env b/sage-env
    old mode 100755
    new mode 100644
    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
     
    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
     
    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.