countries.inc.pl: data/countryInfo.txt
tools/mkcountries-geonames data/countryInfo.txt >$@
+data/caniuse.json:
+ tools/wget-ifmodified http://caniuse.com/data.json $@
+
clean:
-rm digraphs.inc.pl
-rm unicode-char.inc.pl
--- /dev/null
+#!/usr/bin/env sh
+
+set -u
+
+if [ -z "$1" ]
+then
+ echo 'Usage: $0 <url> [<target>]' >&2
+ # download url to target location if modified
+ exit 64 # EX_USAGE
+fi
+
+source=$1
+target=${2:-${source##*/}}
+
+if [ -e "$target" ]
+then
+ modified=$(stat -c%y -L "$target") &&
+ modified=$(date -R -d "$modified")
+ echo download since: $modified
+fi
+
+headers=${modified:+If-Modified-Since: $modified}
+wget -nv --header="$headers" -O "$target.new" "$source" &&
+mv "$target.new" "$target" ||
+rm "$target.new" # clean up failed download (usually empty 304 response)
+