Compare commits

...

2 Commits

Author SHA1 Message Date
e4501794f2 extensions work (for real this time) 2022-11-08 19:38:27 -05:00
78e2bcf9ca fixed wc implementation 2022-11-08 10:16:20 -05:00

View File

@ -29,19 +29,19 @@ fi
# check if we have tomcat(1) # check if we have tomcat(1)
if ! command -v tomcat >/dev/null 2>&1; then if ! command -v tomcat >/dev/null 2>&1; then
printf "%s: Missing dependency: stoml(1)\n" "$argv0" 1>&2 printf "%s: Missing dependency: tomcat(1)\n" "$argv0" 1>&2
exit 71 # sysexits(3) EX_OSERR exit 71 # sysexits(3) EX_OSERR
fi fi
# set the XDG_COMMAND # set the XDG_COMMAND
test -n "$XDG_COMMAND" || XDG_COMMAND="$(tomcat tools.xdg $CONFIG)" test -n "$XDG_COMMAND" || XDG_COMMAND="$(tomcat tools.xdg "$CONFIG")"
! command -v handlr >/dev/null 2>&1 && ! command -v xdg-open >/dev/null 2>&1 \ ! command -v handlr >/dev/null 2>&1 && ! command -v xdg-open >/dev/null 2>&1 \
&& XDG_COMMAND=false \ && XDG_COMMAND=false \
|| true || true
# check if we have a BROWSER # check if we have a BROWSER
test -n "$BROWSER" || BROWSER="$(tomcat tools.browser $CONFIG)" test -n "$BROWSER" || BROWSER="$(tomcat tools.browser "$CONFIG")"
if ! test -n "$BROWSER"; then if ! test -n "$BROWSER"; then
printf "\ printf "\
%s: \$BROWSER not filled. %s: \$BROWSER not filled.
@ -61,39 +61,41 @@ while test -n "$1"; do
xargs echo)" xargs echo)"
# get the pattern for the extensions to MATCH # get the pattern for the extensions to MATCH
MATCH=$(printf "%s\n" "$URL" | sed -ne 's/^h.\+\/\///p' |\ MATCH="$(printf "%s\n" "$URL" | sed -ne 's/^h.\+\/\///p' |\
sed -e 's/\/.*\+//g') sed -e 's/\/.*\+//g')"
# run through MIME extensions # run through MIME extensions
for file in \ for file in \
"$XDG_DATA_HOME"/xdg-sanity/*-mime.toml \ "$XDG_DATA_HOME"/xdg-sanity/*-mime.toml \
/usr/share/xdg-sanity/*-mime.toml \ /usr/share/xdg-sanity/*-mime.toml \
/usr/local/share/xdg-sanity/*-mime.toml \ /usr/local/share/xdg-sanity/*-mime.toml
/dev/null
do do
i=$(tomcat replace.urls "$file" | sed 's/ /\n/g' | xargs wc -l) if test -e "$file"; then
while ! [ "$i" = 0 ]; do i=$(tomcat replace.urls "$file" | sed 's/ /\n/g' | wc -l)
if [ "$MATCH" = "$(tomcat replace.urls[$i] $file)" ]; then while ! [ "$i" = 0 ]; do
MIME=$(tomcat with.mime "$file") if [ "$MATCH" = "$(tomcat replace.urls["$i"] "$file")" ]; then
fi MIME="$(tomcat with.mime "$file")"
i=$(dc -e "$i 1 - p") fi
done i="$(dc -e "$i 1 - p")"
done
fi
done done
# and the replace extensions # and the replace extensions
for file in \ for file in \
"$XDG_DATA_HOME"/xdg-sanity/*-replace.toml \ "$XDG_DATA_HOME"/xdg-sanity/*-replace.toml \
/usr/share/xdg-sanity/*-replace.toml \ /usr/share/xdg-sanity/*-replace.toml \
/usr/local/share/xdg-sanity/*-replace.toml \ /usr/local/share/xdg-sanity/*-replace.toml
/dev/null
do do
i=$(tomcat replace.urls "$file" | sed 's/ /\n/g' | xargs wc -l) if test -e "$file"; then
while ! [ "$i" = 0 ]; do i=$(tomcat replace.urls "$file" | sed 's/ /\n/g' | wc -l)
if [ "$MATCH" = "$(tomcat replace.urls[$i] $file)" ]; then while ! [ "$i" = 0 ]; do
URL=$(tomcat with.url "$file") if [ "$MATCH" = "$(tomcat replace.urls["$i"] "$file")" ]; then
fi URL="$(tomcat with.url "$file")"
i=$(dc -e "$i 1 - p") fi
done i="$(dc -e "$i 1 - p")"
done
fi
done done
# these commands may fail; this is intentional # these commands may fail; this is intentional
@ -102,10 +104,10 @@ while test -n "$1"; do
else else
case "$(command -v $XDG_COMMAND)" in case "$(command -v $XDG_COMMAND)" in
*/handlr ) */handlr )
"XDG_COMMAND" "$MIME" -- "$URL" handlr launch "$MIME" -- "$URL"
;; ;;
*/xdg-open ) */xdg-open )
"$(xdg-mime query default $MIME)" "$URL" "$(xdg-mime query default "$MIME")" "$URL"
;; ;;
false ) false )
exit 69 # sysexits(3) EX_UNAVAILABLE exit 69 # sysexits(3) EX_UNAVAILABLE