tools: optional verbosity for wget-ifmodified
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 16 Jun 2017 15:43:34 +0000 (17:43 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 Jul 2017 15:13:43 +0000 (17:13 +0200)
Silence target date output unless -v is specified.
Build should be more quiet if not debugging.

tools/wget-ifmodified

index bae00f1..05967e1 100755 (executable)
@@ -4,11 +4,20 @@ set -u
 
 if [ -z "$1" ]
 then
-       echo 'Usage: $0 <url> [<target>]' >&2
+       echo 'Usage: $0 [-v] <url> [<target>]' >&2
        # download url to target location if modified
        exit 64 # EX_USAGE
 fi
 
+verbose=
+
+case "$1" in
+-v)
+       verbose=1
+       shift
+       ;;
+esac
+
 source=$1
 target=${2:-${source##*/}}
 
@@ -16,7 +25,7 @@ if [ -e "$target" ]
 then
        modified=$(stat -c%y -L "$target") &&
        modified=$(date -R -d "$modified")
-       echo download since: $modified
+       [ $verbose ] && echo "download since: $modified"
 fi
 
 headers=${modified:+If-Modified-Since: $modified}