Re: SVNNotify - not setting date in header
From: Ryan Schmidt <subversion-2011a_at_ryandesign.com>
Date: Tue, 21 Jun 2011 03:39:52 -0500
On Jun 21, 2011, at 03:24, Miguel Almeida wrote:
> On Mon, 2011-06-20 at 22:17 +0300, Daniel Shahaf wrote:
"-R" is a GNU date extension. BSD date (such as you'll find on Mac OS X or FreeBSD) does not have that option. On public mailing lists like this one (and in general, really), it's good to write portable code (code that can be ported to (m)any system(s)), since people will probably be referring back to it in the archives for years to come, and may not be using the same OS as you.
> And also, what does the LC_ALL=C part mean in the line you suggest?
It sets the locale to C -- in other words, no localization. This ensures the user's (or computer's) locale setting does not make the date command print output in an unexpected locale (language). Your goal is to reproduce the "-R" option of GNU date. The date manpage says this produces a date in RFC 2822 format, which by definition is in English.
http://www.ietf.org/rfc/rfc2822.txt (section 3.3)
The various % options shown in the portable version above however are localized -- shown in different languages, depending on the locale setting. Observe how GNU date displays the output with "-R" the same regardless of the locale:
$ date -R
But that the compatibility version gets localized:
$ date +"%a, %d %b %Y %H:%M:%S %z"
To fix this and make it RFC 2822 compliant, ensure the locale is C.
This is an archived mail posted to the Subversion Users mailing list.