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

Cedric Staniewski cedric at gmx.ca
Sun Nov 1 14:29:20 EST 2009


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


More information about the pacman-dev mailing list