[pacman-dev] [PATCH] makepkg: allow the use of only a package() function

Allan McRae allan at archlinux.org
Sun Nov 1 23:04:32 EST 2009


Cedric Staniewski wrote:
> Isaac Good wrote:
>   
>> On Sun, Nov 01, 2009 at 05:45:27PM +0000, Cedric Staniewski wrote:
>>     
>>> Allan McRae wrote:
>>> >From bash's manpage:
>>>
>>>       
>>>> trap [-lp] [[arg] sigspec ...]
>>>> [...]
>>>> The ERR trap is not executed if the failed command is part of the command
>>>> list immediately following a while or until keyword, part of the test in
>>>> an if statement, part of a command executed in a &&  or  || list,  or if
>>>> the command's return value is being inverted via !.
>>>>         
>>> Note that apparently only the test/[ builtin is meant here.
>>>
>>>       
>> I get the same results with both test/[ as with [[
>>
>> Reusing your code,
>>
>>     
>>> set -E
>>> trap 'echo >&2 "error"' ERR
>>>
>>> false
>>> [ false ]
>>> [[ false ]]
>>> (( 0 ))
>>> ! true
>>>       
>> Only the 'false' by itself triggers the trap. [ and [[ and treated the same.
>>     
>
>
> You missed a small, but important part of the sentence:
>
>   
>> part of the test *in an if statement*
>>     
>
> Consequently, this script
> --------------------
> #!/bin/bash
> set -E
> trap 'echo >&2 "error"' ERR
>
> echo test1
> if test $(type -t package); then
> 	echo 1
> fi
>
> echo test2
> if [ $(type -t package) ]; then
> 	echo 1
> fi
>
> echo test3
> if [[ $(type -t package) ]]; then
> 	echo 1
> fi
>
> echo test4
> if (( $(type -t package) )); then
> 	echo 1
> fi
> --------------------
>
> results in
>
> $ ./test.sh 
> test1
> test2
> test3
> error
> test4
> error
>   

Thanks for the explanation.  This all makes perfect sense to me now.  
Patch is push to my working branch.

Allan




More information about the pacman-dev mailing list