# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1301011752 25200
# Node ID f2d65660e40790a9800970fca3d61da2c2d9fd06
# Parent e78167b9be9fec21405f9312ceabea98b223c41e
#10469: don't source sage-env more than once.
diff -r e78167b9be9f -r f2d65660e407 sage-env
a
|
b
|
|
1 | | #!/usr/bin/env bash |
| 1 | # -*- shell-script -*- |
2 | 2 | |
3 | 3 | ########################################################################### |
4 | 4 | # |
5 | 5 | # Set environment variables for building and/or running Sage. |
6 | | # You must source this; see below! |
7 | | # |
| 6 | # You must *source* this instead of executing; see below! |
| 7 | # |
8 | 8 | # AUTHORS: William Stein 2005-12 |
9 | 9 | # David Kirkby <david.kirkby@onetel.net> 2005-12-17 |
10 | 10 | # |
… |
… |
|
13 | 13 | ########################################################################## |
14 | 14 | # |
15 | 15 | # 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 |
17 | 17 | # |
18 | | # source local/bin/sage-env |
| 18 | # source local/bin/sage-env |
19 | 19 | # |
20 | 20 | # 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 | # |
23 | 23 | ########################################################################## |
24 | 24 | |
25 | 25 | # GUESS SAGE_ROOT from pwd |
… |
… |
|
45 | 45 | exit 1 |
46 | 46 | else |
47 | 47 | SAGE_ROOT="$GUESSED_SAGE_ROOT" |
48 | | export SAGE_ROOT |
| 48 | EXPORT_SAGE_ROOT="yes" |
49 | 49 | fi |
50 | 50 | else |
51 | 51 | if [ -f "$SAGE_ROOT"/sage -a -d "$SAGE_ROOT"/spkg ]; then |
… |
… |
|
62 | 62 | fi |
63 | 63 | fi |
64 | 64 | |
| 65 | # Don't execute the commands more than once. Check this after |
| 66 | # checking the validity of SAGE_ROOT, but before modifying its value. |
| 67 | if [ "x$SAGE_ENV_SOURCED" = "x" ]; then |
| 68 | SAGE_ENV_SOURCED=1 |
| 69 | export SAGE_ENV_SOURCED |
| 70 | else |
| 71 | # Already sourced, nothing to do. |
| 72 | return 0 |
| 73 | fi |
| 74 | |
| 75 | if [ "$EXPORT_SAGE_ROOT" = "yes" ]; then |
| 76 | export SAGE_ROOT |
| 77 | fi |
65 | 78 | |
66 | 79 | # Call with: contains_spaces X${VAR}X |
67 | 80 | # i.e., WITHOUT quotes but some character(s) around the environment variable to test. |