update.sh: set LC_ALL=C when running join command
commite2e0a28b0eb8143a5082e0edc787090d76cebaa4
authorKyle J. McKay <mackyle@gmail.com>
Wed, 24 Dec 2014 03:13:16 +0000 (23 19:13 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Wed, 24 Dec 2014 03:13:16 +0000 (23 19:13 -0800)
treeb4c7cc65b581e67e1973a9e31ef5355af72319f2
parenta54ab93ed1a39dae293b9aa2c60e47117f1e107c
update.sh: set LC_ALL=C when running join command

The refs before and after list is explicitly sorted using sort to make
sure that join works properly.  When using sort LC_ALL is set to C to
guarantee a consistent sort order.

However, LC_ALL was not being set when running join which can result in
warnings whenever input appears to be unsorted or the default value of
LC_*/LANG would sort differently than LC_ALL=C would.

In most cases this would not normally be a problem unless there were
characters greater than 0x7f present in a ref name and the default value
for LC_*/LANG is something that might cause those to sort differently
than LC_ALL=C (such as a UTF-8 locale).

But there appears to be a bug in some versions of sort that can be seen
with the following POSIX shell code:

  for l in C en_US.UTF-8; do
    echo $l:; printf 'A%s/B\r\n' A '' | LC_ALL=$l sort
  done

The correct output looks like this:

  C:
  A/B
  AA/B
  en_US.UTF-8:
  A/B
  AA/B

On systems with the problem (so far only seen on Linux -- Darwin/OS X/
FreeBSD do NOT exhibit the problem) the output looks like this instead:

  C:
  A/B
  AA/B
  en_US.UTF-8:
  AA/B
  A/B

Note that in order to reproduce this problem on an affected system, the
UTF-8 locale used MUST appear in the output of `locale -a`.  The above
uses 'en_US.UTF-8' to test but not all systems support that locale in
which case any other supported (i.e. appears in the output of
`locale -a`) UTF-8 locale may be used instead to reproduce the bug.

This problem appears to be much more common than having characters >
0x7f in a ref name.

To eliminate the join warnings completely for both problems we now set
LC_ALL=C when running join (which now matches the setting when running
sort).
jobd/update.sh