Re: [PATCH 3/4] t: rev-parse-parents: avoid yoda conditions

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

 



On Tue, Sep 03, 2013 at 09:51:07AM +0200, SZEDER Gábor wrote:

> > I wonder if we should have a:
> > 
> >   test_cmp_args () {
> >           echo "$1" >expect &&
> >           echo "$1" >actual &&
> >           test_cmp expect actual
> >   }
> > 
> > to let these remain one-liners like:
> > 
> >   test_cmp_args "$(git rev-parse start)" "$(git rev-parse final^1^1^1)"
> 
> This idea come up before, but there is one flaw which makes this
> function less useful: a non-zero exit code of the commands in the
> command substitutions would be lost.

Good point. You'd probably have to do something gross with eval, like:

  test_cmp_args () {
    eval "$1" >expect &&
    eval "$2" >actual &&
    test_cmp expect actual
  }

but then the callers have to deal with an extra layer of quoting. Not
worth it to save a few lines.

Thanks for a sanity check.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]