Re: [PATCH 4/4] t4200: avoid passing a non-newline terminated file to sed
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 6, 2009, 18:48 UTC
- Message-ID
- <7vhbzyukyi.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <IHOAO7NDkb8K9nkprnkd2ep5vFgQr-bAuDGJW-OdtSbS6WmpSHl041GRSXpP3OcDP4_PsYKsQDU@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
> Some versions of sed exit non-zero if the file they are supplied is not > newline terminated. Solaris's /usr/xpg4/bin/sed is one such sed. So > rework this test to avoid doing so.
I think up to your 3/4 is reasonable, but this is not enough for POSIX conformance (it is Ok if it is just aiming to fix "Solaris quirk"). POSIX sed is only required to work on text files, but .git/MERGE_RR is not a text file (it is a sequence of NUL terminated records).
I think something like this may work better. Can somebody test?
> - sha1=$(sed -e "s/ .*//" .git/MERGE_RR) &&
> + sha1=$({ cat .git/MERGE_RR; echo; } | sed -e "s/ .*//") &&sha1=$(tr "\\000" "\\012" <./git/MERGE_RR | sed -e "s/ .*//") &&