Bug#798175: uupdate: fails if upstream version is 0

James McCoy jamessan at debian.org
Sun Sep 6 18:13:09 UTC 2015


On Sun, Sep 06, 2015 at 08:34:12PM +0900, Osamu Aoki wrote:
> uupdate has a bit cryptic shell contruct:
> 
> | UVERSION=`expr "$SVERSION" : '\(.*\)-[0-9a-zA-Z.+~]*$'` ||
> | {
> |     echo "$PROGNAME: a native Debian package cannot take upstream updates" >&2
> |     exit 1
> | }
> 
> It looks like some expert coding style beyond I would come up but there
> is a catch.
> 
>  * If SVERSION=1-1, uupdate works.
>  * If SVERSION=1, uupdate thinks it is a native Debian package (right).
>  * If SVERSION=0-1, uupdate thinks it is a native Debian package (wrong).
> 
> The reason is the return code of expr is:
>        Exit status is 0 if EXPRESSION is neither null nor 0, 1  if  EXPRESSION
>        is  null  or  0,  2 if EXPRESSION is syntactically invalid, and 3 if an
>        error occurred.
> 
> If SVERSION=1, it is null and return 1.  Good.
> If SVERSION=0-1, it is 0  and return 1.   Not nice!

Good catch!  Thanks.

> So we should ignore return code with 
>  || true

That's not necessary, since we aren't using the return value for
anything.

> and use
>  test -z "$UVERSION"
> to decide if it is a native Debian package or not.

Ack.

Feel free to commit it.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jamessan at debian.org>



More information about the devscripts-devel mailing list