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 bae00f158824bdcd91c3e4538778318d05d7a791..05967e1842744fd26be458bdcfa5e721d480146e 100755 (executable)
@@ -4,11 +4,20 @@ set -u
 
 if [ -z "$1" ]
 then
 
 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
 
        # 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##*/}}
 
 source=$1
 target=${2:-${source##*/}}
 
@@ -16,7 +25,7 @@ if [ -e "$target" ]
 then
        modified=$(stat -c%y -L "$target") &&
        modified=$(date -R -d "$modified")
 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}
 fi
 
 headers=${modified:+If-Modified-Since: $modified}