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

Last change on this file since 143448 was 99822, checked in by raimue@…, 7 years ago

setupenv.bash:
Correctly quote $DISPLAY

  • 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 99822 2012-11-18 11:20:14Z raimue@macports.org $
31
32function export_path() {
33    local binpath="@prefix_expanded@/bin"
34    local sbinpath="@prefix_expanded@/sbin"
35
36    local IFS=":"
37    local p
38
39    for p in $PATH; do
40        if [ "$p" == "$binpath" ]; then
41            binpath=""
42        elif [ "$p" == "$sbinpath" ]; then
43            sbinpath=""
44        fi
45    done
46
47    if [ -n "$binpath" ]; then
48        binpath+=":"
49    fi
50
51    if [ -n "$sbinpath" ]; then
52        sbinpath+=":"
53    fi
54
55    export PATH="${binpath}${sbinpath}${PATH}"
56}
57
58function export_manpath() {
59    local mpath="@prefix_expanded@/share/man"
60    local IFS=":"
61    local p
62
63    if [ -z "$MANPATH" ]; then
64        return
65    fi
66
67    for p in $MANPATH; do
68        if [ "$p" == "$mpath" ]; then
69            mpath=""
70        fi
71    done
72
73    if [ -n "$mpath" ]; then
74        mpath+=":"
75    fi
76
77    export MANPATH="${mpath}${MANPATH}"
78}
79
80function export_display() {
81    if [ -z "$DISPLAY" ]; then
82        export DISPLAY=":0.0"
83    fi
84}
85
86export_path
87export_manpath
88export_display
89
90# Remove defined functions to prevent them from cluttering the shell,
91# but they are needed to restrict variables to the local scope
92unset export_path
93unset export_manpath
94unset export_display
Note: See TracBrowser for help on using the repository browser.