On 09/20/2017 07:45 PM, Fam Zheng wrote:
>>
>> 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 "${PIPESTATUS[@]}" != "0 0"; then
> 
> Hmm, with exactly this line here I get something like:
> 
> ./scripts/archive-source.sh: line 36: test: too many arguments

D'oh - [@] causes word splitting (same as "$@"); we want [*] instead:

if test "${PIPESTATUS[*]}" != "0 0";

> 
> But with
> 
>     if test "${PIPESTATUS[0]} ${PIPESTATUS[1]}" != "0 0"; then

or that's a manual way of spelling the auto-array-concatenation that you
get with [*].

> 
> it seems to work fine. What is the magic here?
> 
> Fam
> 

-- 
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