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

Andres P aepd87 at gmail.com
Tue May 25 16:06:41 EDT 2010

On Sat, May 22, 2010 at 2:18 AM, Allan McRae <allan at archlinux.org> wrote:
> In fact, thinking about this more.  Bash-4.1 was released on 2010-01-03 so
> it will have been out for ~6 months before the next pacman release. Anyone
> upgrading their package manager from 3.3 -> 3.4 will upgrade bash from 4.0
> -> 4.1 so this is probably a non-issue.
> So I will accept this patch when the comment above and "stray" ! is removed
> with it.
> Allan
I was about to do that, but first I think I should talk about another

`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

Even though there is a negligible perfomance difference in makepkg, this
is the correct way to check for $?.

If the redir to /dev/null becomes to much of a burden to type, it could
become a function. Not to mention that the whole series of checking
for vcs in PATH, which is where most of `type p` gets used, could be
changed in to a more platable chunk.

Would there be interest in making this change?

I really think that throwing away the return val and making a string
check is poor practice.

Andres P

More information about the pacman-dev mailing list