source: branches/variant-descs-14482/base/setupenv.bash.in @ 42663

Last change on this file since 42663 was 42632, checked in by blb@…, 12 years ago

Merged revisions 42584 via svnmerge from
https://svn.macports.org/repository/macports/trunk/base

........

r42584 | jkh@… | 2008-11-25 01:33:48 -0700 (Tue, 25 Nov 2008) | 2 lines


bring prefix into scope before using

........

File size: 2.8 KB
Line 
1# -*- coding: utf-8; mode: shell-script-mode; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=sh:et:sw=4:ts=4:sts=4
2#
3# Copyright (c) 2008 Rainer Mueller <raimue@macports.org>, The MacPorts Project.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14# 3. Neither the name of Apple, Inc., The MacPorts Project nor the
15#    names of its contributors may be used to endorse or promote products
16#    derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30# $Id: setupenv.bash.in 42632 2008-11-27 08:52:05Z blb@macports.org $
31
32function export_path() {
33    local binpath="@prefix_expanded@/bin"
34    local sbinpath="@prefix_expanded@/sbin"
35
36    local IFS=":"
37    for p in $PATH; do
38        if [ "$p" == "$binpath" ]; then
39            binpath=""
40        elif [ "$p" == "$sbinpath" ]; then
41            sbinpath=""
42        fi
43    done
44
45    if [ -n "$binpath" ]; then
46        binpath+=":"
47    fi
48
49    if [ -n "$sbinpath" ]; then
50        sbinpath+=":"
51    fi
52
53    export PATH="${binpath}${sbinpath}${PATH}"
54}
55
56function export_manpath() {
57    mpath="@prefix_expanded@/share/man"
58
59    local IFS=":"
60    for p in $MANPATH; do
61        if [ "$p" == "$mpath" ]; then
62            mpath=""
63        fi
64    done
65
66    if [ -n "$mpath" ]; then
67        mpath+=":"
68    fi
69
70    export MANPATH="${mpath}${MANPATH}"
71}
72
73function export_display() {
74    if [ -z $DISPLAY ]; then
75        export DISPLAY=":0.0"
76    fi
77}
78
79export_path
80export_manpath
81export_display
82
83# Remove defined functions to prevent them from cluttering the shell,
84# but they are needed to restrict variables to the local scope
85unset export_path
86unset export_manpath
87unset export_display
Note: See TracBrowser for help on using the repository browser.