Compare commits

..

No commits in common. "e4501794f2b8f9fd6b022f8bcd03ef1307810a40" and "5ca13548d737b8a54e566b2f1de6cb76f7ba79c4" have entirely different histories.

View File

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