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

Isaac Good pacman at isaac.otherinbox.com
Tue Nov 10 16:17:09 EST 2009


On Sun, Nov 01, 2009 at 07:29:20PM +0000, 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
> 
 
I brought this up in FreeNode/#bash and at the very least there is an error in the man pages. More likely a bug in [[. This should be reported upstream to Chet (bash).
 - Isaac



More information about the pacman-dev mailing list