aboutsummaryrefslogtreecommitdiff
path: root/bin/spexactivate
blob: a4667788f8119b8bc61dd32018243ab468d7c34d (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
#!/usr/bin/env bash
# vim: tabstop=4 shiftwidth=4 expandtab
topdir="$( dirname $(cd $(dirname ${BASH_SOURCE[0]}) && pwd) )"
datadir="${topdir}/share"
spexdir="${topdir}/spex"

spextool_version="$1"
if [ -z "$spextool_version" ]; then
    echo "usage: source $(basename $0) {release}" >&2
    return 1
fi

root="${spexdir}/${spextool_version}"
if [ ! -d "$root" ]; then
    echo "$spextool_version is not installed" >&2
    return 1
fi

if [ -n "$IDL_PATH" ] && [ -z "$IDL_PATH_OLD" ]; then
    IDL_PATH_OLD="$IDL_PATH"
    export IDL_PATH_OLD
else
    IDL_PATH_OLD="+$IDL_DIR"
    export IDL_PATH_OLD
fi

paths="+${datadir}:+${root}"
if ! [[ "$IDL_PATH" =~ .*"$paths".* ]]; then
    unset IDL_PATH
    IDL_PATH="${paths}:${IDL_PATH_OLD}:+${IDL_DIR}"
fi
export IDL_PATH