summaryrefslogtreecommitdiffstats
path: root/solenv/bin/lo_find_src_root
blob: a91c84759822b4069116d6666e82f5532a93f22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
#
# (c) 2011  Norbert Thiebaud. License : GPLv3
#
# try to locate the SRC_ROOT based on the working directory
# we search for first Repository.mk
# in the current directoyr or its parent, all teh way to /
# Ths is a heuristic. it works 'most of the times
# but it could give false positive if you try hard enough
#

current=$(pwd)

while [  "${current}" != "/" ] ; do
    if [ -f ${current}/.src_root ] ; then
        echo "${current}"
        exit 0;
    fi
    current=$(dirname "${current}")
done

echo "Error cannot determine SRC_ROOT" 1>&2
exit 1;