[pacman-dev] [PATCH] [makepkg] use double brackets
Allan McRae
allan at archlinux.org
Fri May 28 23:33:27 EDT 2010
On 29/05/10 05:16, Andres P wrote:
> 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.
Sure. It is much faster to check for functions that way.
Feel free to base it of my post-3.4 branch is you want to do this pre
pacman-3.4 release.
Allan
More information about the pacman-dev
mailing list