--- install-font.sh.orig 2020-08-02 07:40:54.598224649 -0400 +++ install-font.sh 2020-08-02 08:30:09.915547433 -0400 @@ -223,6 +223,18 @@ Aborting.\n" >&2 Aborting.\n" >&2 exit 1 ;; + not_dir) + printf \ +"[install-font]: \"${OPTARG}\" not a directory. \ +Aborting.\n" >&2 + exit 1 + ;; + not_writable) + printf \ +"[install-font]: \"${OPTARG}\" is not writable. \ +Aborting.\n" >&2 + exit 1 + ;; incompatible) printf \ "[install-font]: Incompatible file type. Must have extension ttf|pfa|pfb|otf. \ @@ -465,6 +477,16 @@ check_optarg() : } +check_optarg_dir() +{ + [ "${OPTARG:0:1}" = "-" ] && error no_arg # is an opt when arg to opt expected + + [ ! -d "${OPTARG}" ] && error not_dir + + [ ! -w "${OPTARG}" ] && error not_writable + : +} + while getopts ":C:cndDF:f:hHlpP:s" opt do case "$opt" in @@ -519,7 +541,7 @@ do ;; P) option=P - check_optarg + check_optarg_dir loc_or_sysdir=${OPTARG} ;; p)