[pacman-dev] [PATCH] [makepkg] use double brackets

Andres P aepd87 at gmail.com
Fri May 28 15:16:50 EDT 2010


On Tue, May 25, 2010 at 03:36:41PM -0430, Andres P wrote:
> `type -p foo` has a return val, so consider this:
>     $ time for i in {1..1000}; do [[ $(type -p sh) ]]; done
>     real    0m1.564s
>     user    0m0.160s
>     sys 0m0.337s
> 
>     $ time for i in {1..1000}; do type -p sh &>/dev/null; done
>     real    0m0.166s
>     user    0m0.060s
>     sys 0m0.103s
>
I should have brought this up sooner:

    check_fn() { 
    #   if [[ $(type -t "$1") = "function" ]]; then
        if declare -f "$1" >/dev/null; then
            echo true
        else
            echo false
        fi
    }

    build() { :; }

    check_fn build # true

    unset build

    check_fn build # false

    check_fn bash  # false

Assuming there's interest, I'll write a patch once master i open again.

Andres P


More information about the pacman-dev mailing list