qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 03/13] scripts: Add archive-source.sh


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v10 03/13] scripts: Add archive-source.sh
Date: Wed, 20 Sep 2017 08:20:02 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 09/19/2017 10:25 PM, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  scripts/archive-source.sh | 51 
> +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>  create mode 100755 scripts/archive-source.sh
> 

> +
> +if test -n "$submodules"; then
> +    {
> +        git ls-files || error "git ls-files failed"
> +        for sm in $submodules; do
> +            (cd $sm; git ls-files) | sed "s:^:$sm/:"
> +            if test ${PIPESTATUS[0]} -ne 0 -o $? -ne 0; then

This relies on 'test ... -o ...' which is non-portable.  It "works"
because there is no possible ambiguity in the contents of $PIPESTATUS
that could cause a different parse of the test arguments, but I tend to
discourage any use of -a/-o inside test on principle.  Sadly, writing:

if test ${PIPESTATUS[0]} -ne 0 || test $? -ne 0

has a flaw that $? is no longer what you want, at which point you would
have to introduce a temporary variable.  But we're using bash, so you
can instead write this as:

if test "address@hidden" != "0 0"; then

> +                error "git ls-files in submodule $sm failed"
> +            fi
> +        done
> +    } | grep -x -v $(for sm in $submodules; do echo "-e $sm"; done) > 
> "$1".list
> +else
> +    git ls-files > "$1".list
> +fi

At this point, $1.list has been created, even if commands failed...

> +
> +if test $? -ne 0; then
> +    error "failed to generate list file"
> +fi

...but this exits without cleanup.  If we really want it cleaned no
matter what, it's probably better to do:

trap "status=$?; rm -f "$1".list; exit \$status" 0 1 2 3 15

earlier than anything that can create the file.

> +
> +tar -cf "$1" -T "$1".list
> +status=$?
> +rm "$1".list
> +if test $statue -ne 0; then

Umm, $statue is not the same as $status.

> +    error "failed to create tar file"
> +fi
> +exit 0
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]