URI: 
       curl-grabtitle: do not try to get title for non-HTML URLs - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 408ac5316fd5a2b720b21bc5ae11db810bf33a7b
   DIR parent a3e40e235d62c466db9c6c9a50b4e80ecad24958
  HTML Author: Quentin Rameau <quinq@fifth.space>
       Date:   Thu, 15 Jul 2021 00:24:15 +0200
       
       curl-grabtitle: do not try to get title for non-HTML URLs
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         M curl-grabtitle                      |       7 ++++---
         M fetch-uri                           |      20 +++++++++++++++++---
       
       2 files changed, 21 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/curl-grabtitle b/curl-grabtitle
       @@ -1,11 +1,12 @@
        #!/bin/sh
        export PATH="$HOME/bin:$PATH"
        
       -if [ $# -lt 1 ];
       +if [ $# -lt 1 ]
        then
       -        printf "usage: %s\n" "$(basename "$0")" >&2
       +        printf "usage: %s URI\n" "$(basename "$0")" >&2
                exit 1
        fi
        
       -fetch-uri "$1" | grabtitle
       +fetch-uri -h "$1" | grep '^content-type:.* text/html' >/dev/null 2>&1 || exit
        
       +fetch-uri "$1" | grabtitle
   DIR diff --git a/fetch-uri b/fetch-uri
       @@ -1,9 +1,22 @@
        #!/bin/sh
        
       -if [ $# -lt 1 ];
       -then
       -        printf "usage: %s\n" "$(basename "$0")" >&2
       +set -x
       +
       +usage() {
       +        printf "usage: %s [-h] URI\n" "$(basename "$0")" >&2
                exit 1
       +}
       +
       +if [ $# -lt 1 ] || [ $# -gt 2 ]
       +then
       +        usage
       +fi
       +
       +if [ $# -eq 2 ]
       +then
       +        [ $1 = -h ] || usage
       +        opth=-I
       +        shift
        fi
        
        curl \
       @@ -12,4 +25,5 @@ curl \
                -L --max-redirs 3 \
                -m 5 \
                -H 'User-Agent:' \
       +        $opth \
                "$1" 2>/dev/null