Re: [PATCH 2/4] builtin/rev-parse: learn --null-oid
On Sep 18 2020, brian m. carlson wrote:
Show 11 quoted lines
> What I typically do when I write shell scripts, and which may obviate
> the need for this patch is turn this:
>
> [ "$oid" = 0000000000000000000000000000000000000000 ]
>
> into this:
>
> echo "$oid" | grep -qsE '^0+$'
>
> This is slightly less efficient, but it's also backwards compatible
> with older Git version assuming you have a POSIX grep.
You can also use
case $oid in *[1-9a-f]*) ... ;; *) ... ;; esac
which doesn't need an external process.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."