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