source: trunk/base/setupenv.bash.in @ 73358

Last change on this file since 73358 was 64422, checked in by raimue@…, 11 years ago

steupenv.bash:
Do not set MANPATH if it is empty as man will automatically map PATH in this case

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 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 64422 2010-03-05 14:39:24Z raimue@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    if [ -z "$MANPATH" ]; then
60        return
61    fi
62
63    local IFS=":"
64    for p in $MANPATH; do
65        if [ "$p" == "$mpath" ]; then
66            mpath=""
67        fi
68    done
69
70    if [ -n "$mpath" ]; then
71        mpath+=":"
72    fi
73
74    export MANPATH="${mpath}${MANPATH}"
75}
76
77function export_display() {
78    if [ -z $DISPLAY ]; then
79        export DISPLAY=":0.0"
80    fi
81}
82
83export_path
84export_manpath
85export_display
86
87# Remove defined functions to prevent them from cluttering the shell,
88# but they are needed to restrict variables to the local scope
89unset export_path
90unset export_manpath
91unset export_display
Note: See TracBrowser for help on using the repository browser.