The linux version of homebrew installs groff's data directory in
/home/linuxbrew/.linuxbrew/share/groff by default.
I must have cargo culted the check_optarg without checking everything out
when I added the -P option. I've attached a patch to install-font.sh to
make it check that the argument to -P is a directory and that it is
writable.
I kept the check that the argument doesn't start with a dash, even though
someone evil might start their directory with a dash. Should that check be
dropped?
--
T. Kurt Bond, [email protected], https://tkurtbond.github.io
--- 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)