Total rewrite #15

Merged
emma merged 14 commits from rewrite into main 2023-03-22 12:42:30 -06:00
Showing only changes of commit 00bd98df9a - Show all commits

View File

@ -8,12 +8,7 @@ argv0="$0"
CONFIG="$XDG_CONFIG_HOME"/xdg-sanity.toml
if ! test -e "$CONFIG"; then
touch "$CONFIG"
CONFIG=/etc/xdg-sanity.toml
if ! test -e "$CONFIG"; then
exit 66 # sysexits(3) EX_NOINPUT
fi
fi
# check if usage is valid
if ! test -n "$1"; then
@ -24,13 +19,13 @@ fi
# check if we have curl(1)
if ! command -v curl >/dev/null 2>&1; then
printf "%s: Missing dependency: curl(1)\n" "$argv0" 1>&2
exit 71 # sysexits(3) EX_OSERR
exit 69 # sysexits(3) EX_UNAVAILABLE
fi
# check if we have tomcat(1)
if ! command -v tomcat >/dev/null 2>&1; then
printf "%s: Missing dependency: tomcat(1)\n" "$argv0" 1>&2
exit 71 # sysexits(3) EX_OSERR
exit 69 # sysexits(3) EX_UNAVAILABLE
fi
# set the XDG_COMMAND
@ -39,14 +34,13 @@ test -n "$XDG_COMMAND" || XDG_COMMAND="$(tomcat tools.xdg "$CONFIG")"
&& XDG_COMMAND=false \
|| true
# check if we have a BROWSER
test -n "$BROWSER" || BROWSER="$(tomcat tools.browser "$CONFIG")"
if ! test -n "$BROWSER"; then
printf "\
%s: \$BROWSER not filled.
Please place the path to your preferred browser's executable in
$XDG_CONFIG_HOME/xdg-sanity.conf or /etc/xdg-sanity.conf
$XDG_CONFIG_HOME/xdg-sanity.toml
" "$argv0" 1>&2
exit 71 # sysexits(3) EX_OSERR
fi
@ -88,7 +82,7 @@ while test -n "$1"; do
/usr/local/share/xdg-sanity/*-replace.toml
do
if test -e "$file"; then
i=$(tomcat replace.urls "$file" | sed 's/ /\n/g' | wc -l)
i="$(tomcat replace.urls "$file" | sed 's/ /\n/g' | wc -l)"
while ! [ "$i" = 0 ]; do
if [ "$MATCH" = "$(tomcat replace.urls["$i"] "$file")" ]; then
URL="$(tomcat with.url "$file")"