diff options
author | Michael Reed <michael@michaelreed.io> | 2017-07-10 19:14:33 -0400 |
---|---|---|
committer | Michael Reed <michael@michaelreed.io> | 2017-07-10 20:26:39 -0400 |
commit | bfc86546849e15dd98362852e76fa9feac2fba77 (patch) | |
tree | 5f9cbc546b1b9de8887e17321facff4383a8e24b | |
parent | c41354732a1e863be0dfc62218f29df81479c151 (diff) | |
download | librebootfr-bfc86546849e15dd98362852e76fa9feac2fba77.tar.gz librebootfr-bfc86546849e15dd98362852e76fa9feac2fba77.zip |
www/index.sh: Fix OpenBSD touch(1) incompatibility
When running index.sh on OpenBSD, the following error happens for
each item in the news/ directory (output is from "bash -x"):
+ touch -d '4 Jun 2017' news/andrew-robbins-new-maintainer.md
touch: out of range or illegal time specification: YYYY-MM-DDThh:mm:ss[.frac][Z]
This is because OpenBSD's touch(1) requires that the "d" flag's argument
be in ISO 8601 format, that is, "YYYY-MM-DDThh:mm:ss[.frac][Z]". This
could have been dealt with by converting the article date (determined
by "sed -n 3p $f | sed -e 's/^..//g'") to ISO 8601 format, then passing
the date to touch(1). That would have required even more code, so was
discarded as a possible solution.
Instead, this has been solved by prepending the ISO 8601 date to the names
of all news items. This has the benefit of avoiding the need for touch(1)
altogether, as a lexicographic sorting of ISO 8601 dates is the same as
a date-based sorting. In other words, "ls news/*.md" will give a list
of articles sorted by date, which we can then append to news/index.md in
that order.
One downside of this solution is that it introduces the possibility that
the date in the filename (ISO 8601 format) of a news article does not
match the date inside the article (e.g., 1 May 2017). I have not dealt
with this as it remains to be seen whether it will be a problem in
practice.
-rwxr-xr-x | www/index.sh | 3 | ||||
-rw-r--r-- | www/news/20170402-unity.md (renamed from www/news/unity.md) | 0 | ||||
-rw-r--r-- | www/news/20170422-proposal-rejoin-gnu.md (renamed from www/news/proposal-rejoin-gnu.md) | 0 | ||||
-rw-r--r-- | www/news/20170425-formalised-structure.md (renamed from www/news/formalised-structure.md) | 0 | ||||
-rw-r--r-- | www/news/20170604-andrew-robbins-new-maintainer.md (renamed from www/news/andrew-robbins-new-maintainer.md) | 0 | ||||
-rw-r--r-- | www/news/20170610-new-mailing-lists.md (renamed from www/news/new-mailing-lists.md) | 0 |
6 files changed, 1 insertions, 2 deletions
diff --git a/www/index.sh b/www/index.sh index 4d7d2292..9b6bd7f0 100755 --- a/www/index.sh +++ b/www/index.sh @@ -37,13 +37,12 @@ meta() { # generate the index file -FILES=$(ls -1 -t news/*.md | sed -e s-.*index.md-- -e s-.*presentation.md--) +FILES=$(ls -r1 news/*.md | sed -e s-.*index.md-- -e s-.*presentation.md--) cat news-list.md > news/index.md for f in $FILES do - touch -d "$(sed -n 3p $f | sed -e 's/^..//g')" $f meta >> news/index.md done diff --git a/www/news/unity.md b/www/news/20170402-unity.md index b44f04e0..b44f04e0 100644 --- a/www/news/unity.md +++ b/www/news/20170402-unity.md diff --git a/www/news/proposal-rejoin-gnu.md b/www/news/20170422-proposal-rejoin-gnu.md index 795821e1..795821e1 100644 --- a/www/news/proposal-rejoin-gnu.md +++ b/www/news/20170422-proposal-rejoin-gnu.md diff --git a/www/news/formalised-structure.md b/www/news/20170425-formalised-structure.md index a630ff23..a630ff23 100644 --- a/www/news/formalised-structure.md +++ b/www/news/20170425-formalised-structure.md diff --git a/www/news/andrew-robbins-new-maintainer.md b/www/news/20170604-andrew-robbins-new-maintainer.md index 50c43d3a..50c43d3a 100644 --- a/www/news/andrew-robbins-new-maintainer.md +++ b/www/news/20170604-andrew-robbins-new-maintainer.md diff --git a/www/news/new-mailing-lists.md b/www/news/20170610-new-mailing-lists.md index 8d623331..8d623331 100644 --- a/www/news/new-mailing-lists.md +++ b/www/news/20170610-new-mailing-lists.md |