On Mon, Jan 23, 2012 at 12:48:37PM +1000, Allan McRae wrote:
> On 23/01/12 12:13, Dave Reisner wrote:
> > On Mon, Jan 23, 2012 at 12:08:14PM +1000, Allan McRae wrote:
> >> On 20/01/12 23:59, Dave Reisner wrote:
> >>> On Fri, Jan 20, 2012 at 11:24:23PM +1000, Allan McRae wrote:
> >>>> The grep statement used to check for a difference between the
> >>>> installed package list before and after resolving dependencies
> >>>> returns 1 if there is no difference.  This sets of the error
> >>>> trap when "-r" is used "unnecessarily".
> >>>>
> >>>> Signed-off-by: Allan McRae <al...@archlinux.org>
> >>>> ---
> >>>>
> ...
> >>>>  
> >>>>          local deplist
> >>>> -        if ! deplist=($(grep -xvFf <(printf "%s\n" 
> >>>> "${original_pkglist[@]}") \
> >>>> -                        <(printf "%s\n" "${current_pkglist[@]}"))); then
> >>>> +        deplist=($(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") 
> >>>> \
> >>>> +                        <(printf "%s\n" "${current_pkglist[@]}") || 
> >>>> true))
> >>>> +        if [[ -n deplist ]]; then
> >>>
> >>> My brain tells me there's a way to avoid this, but I'm not sure I trust
> >>> it right now.
> >>>
> >>
> >> I have not thought of one...  let me know if your brain is working
> >> better now and has come up with the answer!
> >>
> >>
> > 
> > What about something like...
> > 
> >   local dep deplist
> >   while read -r dep; do
> >     deplist+=("$dep")
> >   done < <(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") \
> >       <(printf "%s\n" "${current_pkglist[@]}"))
> > 
> >   if (( ${#deplist[*]} )); then
> >     return
> >   fi
> 
> I'm not sure the whole "while read" construct is worth it to get rid of
> the || true.   I'll just leave my patch as it is for now unless you
> really feel strongly that I should not do it that way...
> 
> Allan
> 

Yeah, I'm not sure either. Ideally we'd have something decent like an
array_diff or array_subtract function, but passing arrays in bash is
an undocumented feature and otherwise awful to do "properly".


Reply via email to