about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/emacs/wrapper.sh
blob: e8eecb8c869668d4e762b173f0743e46d0b6ad6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!@bash@

IFS=:

newLoadPath=()
newNativeLoadPath=()
added=

if [[ -n $EMACSLOADPATH ]]
then
    while read -rd: entry
    do
        if [[ -z $entry && -z $added ]]
        then
            newLoadPath+=(@wrapperSiteLisp@)
            added=1
        fi
        newLoadPath+=("$entry")
    done <<< "$EMACSLOADPATH:"
else
    newLoadPath+=(@wrapperSiteLisp@)
    newLoadPath+=("")
fi

if [[ -n $EMACSNATIVELOADPATH ]]
then
    while read -rd: entry
    do
        if [[ -z $entry && -z $added ]]
        then
            newNativeLoadPath+=(@wrapperSiteLispNative@)
            added=1
        fi
        newNativeLoadPath+=("$entry")
    done <<< "$EMACSNATIVELOADPATH:"
else
    newNativeLoadPath+=(@wrapperSiteLispNative@)
    newNativeLoadPath+=("")
fi

export EMACSLOADPATH="${newLoadPath[*]}"
export emacsWithPackages_siteLisp=@wrapperSiteLisp@

export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@

exec @prog@ "$@"