On Thu, Nov 12, 2015 at 10:36:16PM -0600, David A. Greene wrote:

> > +                           sub="$(git rev-parse "$b^0")" || die "could not 
> > rev-parse split hash $b from commit $sq"
> 
> This seems like odd quoting.  Would not this do the same?
> 
>                               sub="$(git rev-parse $b^0)" || die "could not 
> rev-parse split hash $b from commit $sq"
> 
> Perhaps I am missing something.

The former is quoting "$b" against whitespace splitting in the
sub-command. Given that the value just came from a "read" call, I think
by definition it cannot contains IFS. Still, quoting here is a good
habit.

It is actually the _outer_ quotes that are unnecessary, as variable
assignment does not do extra splitting. So:

  foo=$(echo one two)

will put the full "one two" into $foo. But the quotes do not hurt
anything, and it is a reasonable style to use them to avoid this
discussion. :)

It also matches style-wise with nearby assignments, like:

  main="$b"

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

Reply via email to