Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit d8ff6916 authored by Kyle Ladd's avatar Kyle Ladd Committed by Michael Bestas
Browse files

build: fix bash completion sourcing

Sourcing functions in files from a function within a file being
sourced was giving bash a hard time. This fixes 'repo' command tab
completions.

Change-Id: Iac1b3078e20749fb474ed1270e0886cf435e24d9
parent b4443d3a
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -331,29 +331,19 @@ function settitle()
    fi
}

function addcompletions()
function check_bash_version()
{
    # Keep us from trying to run in something that isn't bash.
    if [ -z "${BASH_VERSION}" ]; then
        return
        return 1
    fi

    # Keep us from trying to run in bash that's too old.
    if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
        return
        return 2
    fi

    local T dir f

    dirs="sdk/bash_completion vendor/cm/bash_completion"
    for dir in $dirs; do
    if [ -d ${dir} ]; then
        for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
            echo "including $f"
            . $f
        done
    fi
    done
    return 0
}

function choosetype()
@@ -1680,6 +1670,17 @@ do
done
unset f

addcompletions
# Add completions
check_bash_version && {
    dirs="sdk/bash_completion vendor/cm/bash_completion"
    for dir in $dirs; do
    if [ -d ${dir} ]; then
        for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
            echo "including $f"
            . $f
        done
    fi
    done
}

export ANDROID_BUILD_TOP=$(gettop)