On Sat, Oct 07, 2017 at 05:34:15PM +0200, Christoph Berg wrote:

> Re: Karsten Hilbert 2017-10-07 
> <20171007152609.i4m5zc6yuol4j...@hermes.hilbert.loc>
>>>>     return ($ctype, $collate) unless $?;
> > 
> > Actually, isn't this inverted logic ?
> > 
> > It should return(...) unless $? actually is NOT zero ?
> 
> The extracted values should be returned if the last psql call exited
> with status 0. (Yes this function isn't the most pretty one. I'm
> inclined to rewrite the whole psql handling from scratch...)

I'll try to think it through although I am not a perl expert:

        psql <yadayada>

        success

        now $? is 0 (which is "FALSE")

        return ($ctype, $collate) unless $?;

        definition: statement unless condition

        execute statement unless condition is true

        condition: $? which is 0 which is "FALSE"

        statement: "return" ($ctype, $collate)

        hence: execute "return" unless "FALSE" is true

Won't work, right ?

It should be

        return ($ctype, $collate) unless ($? != 0);

or am I mistaken ?

Karsten
-- 
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

Reply via email to