summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennard Hofmann <lennard.hofmann@web.de>2023-08-20 13:45:55 +0200
committerSimon Lees <simon@simotek.net>2023-08-30 04:35:34 +0000
commitd0b765f4879ea784bfa3c4cb91e5c9240e5df52e (patch)
tree79a8142304eec70908898e90f328f68cb2aecb9f
parentc22a09fc4f2d676404b4cf3ef27294aec7c8c09f (diff)
shellcheck fixes; make xdg-mime DASH-compatible
-rw-r--r--scripts/xdg-desktop-icon.in2
-rw-r--r--scripts/xdg-desktop-menu.in16
-rw-r--r--scripts/xdg-email.in21
-rw-r--r--scripts/xdg-file-dialog.in30
-rw-r--r--scripts/xdg-icon-resource.in4
-rw-r--r--scripts/xdg-mime.in12
-rwxr-xr-xscripts/xdg-open.in4
-rw-r--r--scripts/xdg-screensaver.in10
-rwxr-xr-xscripts/xdg-settings.in26
-rw-r--r--scripts/xdg-utils-common.in4
10 files changed, 59 insertions, 70 deletions
diff --git a/scripts/xdg-desktop-icon.in b/scripts/xdg-desktop-icon.in
index c755174..6417181 100644
--- a/scripts/xdg-desktop-icon.in
+++ b/scripts/xdg-desktop-icon.in
@@ -89,7 +89,7 @@ filetype=
case "$desktop_file" in
*.desktop)
filetype=desktop
- if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ if [ "$vendor" = "true" ] && [ "$action" = "install" ] ; then
check_vendor_prefix "$desktop_file"
fi
;;
diff --git a/scripts/xdg-desktop-menu.in b/scripts/xdg-desktop-menu.in
index 19e20dd..8025676 100644
--- a/scripts/xdg-desktop-menu.in
+++ b/scripts/xdg-desktop-menu.in
@@ -161,20 +161,20 @@ update_submenu()
mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'`
if [ ! -e "$mandrake_xdg_dir" ] ; then
DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'"
- mkdir -p `dirname "$mandrake_xdg_dir"`
+ mkdir -p "`dirname "$mandrake_xdg_dir"`"
eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output
fi
fi
- if [ $action = "install" -a x"$mode" = x"user" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] ; then
+ if [ $action = "install" ] && [ x"$mode" = x"user" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] ; then
# Work around for Fedora Core 5 + patched KDE
kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
if [ ! -e "$kde_xdg_dir" ] ; then
DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'"
- mkdir -p `dirname "$kde_xdg_dir"`
+ mkdir -p "`dirname "$kde_xdg_dir"`"
eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output
fi
fi
- if [ $action = "install" -a x"$mode" = x"system" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] && [ ! -d "/etc/xdg/menus/applications-merged" ] ; then
+ if [ $action = "install" ] && [ x"$mode" = x"system" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] && [ ! -d "/etc/xdg/menus/applications-merged" ] ; then
# Work around for Kubuntu 6.06
kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'"
@@ -283,7 +283,7 @@ BEGIN {
if [ $action = "uninstall" ] ; then
test "${TMPDIR+set}" = set || TMPDIR=/tmp
tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
- for menu_file in $xdg_dir/*; do
+ for menu_file in "$xdg_dir"/*; do
if grep 'generated and managed by @NAME@' "$menu_file" > /dev/null 2> /dev/null; then
awk '
# List all files within <Directory> tags
@@ -412,7 +412,7 @@ if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
fi
if [ -z "$mode" ] ; then
- if [ `whoami` = "root" ] ; then
+ if [ "`id -u`" -eq 0 ] ; then
mode="system"
else
mode="user"
@@ -430,7 +430,7 @@ fi
menu_name=
for desktop_file in $directory_files; do
- if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ if [ "$vendor" = "true" ] && [ "$action" = "install" ] ; then
check_vendor_prefix "$desktop_file"
fi
@@ -560,7 +560,7 @@ else
fi
for desktop_file in $desktop_files; do
- if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ if [ "$vendor" = "true" ] && [ "$action" = "install" ] ; then
check_vendor_prefix "$desktop_file"
fi
diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
index 43ddfcc..6135b24 100644
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -142,10 +142,9 @@ open_gnome3()
local desktop
desktop=`xdg-mime query default "x-scheme-handler/mailto"`
client=`desktop_file_to_binary "$desktop"`
- echo $client | grep -E 'thunderbird|icedove' > /dev/null 2>&1
- if [ $? -eq 0 ] ; then
+ case $client in *thunderbird*|*icedove*)
run_thunderbird "$client" "$1"
- fi
+ esac
if gio help open 2>/dev/null 1>&2; then
DEBUG 1 "Running gio open \"$1\""
@@ -168,11 +167,10 @@ open_gnome3()
open_gnome()
{
local client
- client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1` || ""
- echo $client | grep -E 'thunderbird|icedove' > /dev/null 2>&1
- if [ $? -eq 0 ] ; then
+ client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1`
+ case $client in *thunderbird*|*icedove*)
run_thunderbird "$client" "$1"
- fi
+ esac
if gio help open 2>/dev/null 1>&2; then
DEBUG 1 "Running gio open \"$1\""
@@ -243,10 +241,9 @@ open_generic()
local desktop
desktop=`xdg-mime query default "x-scheme-handler/mailto"`
client=`desktop_file_to_binary "$desktop"`
- echo $client | grep -E 'thunderbird|icedove' > /dev/null 2>&1
- if [ $? -eq 0 ] ; then
+ case $client in *thunderbird*|*icedove*)
run_thunderbird "$client" "$1"
- fi
+ esac
xdg-open "$1"
exit $?
@@ -374,7 +371,7 @@ while [ $# -gt 0 ] ; do
*@*)
url_encode "$parm"
if [ -z "${mailto}" ] ; then
- mailto="mailto:"${result}"?"
+ mailto="mailto:${result}?"
else
options="${options}to=${result}&"
fi
@@ -460,7 +457,7 @@ case "$DE" in
;;
flatpak)
- open_flatpak "$url"
+ open_flatpak "${mailto}"
;;
generic|lxqt|enlightenment)
diff --git a/scripts/xdg-file-dialog.in b/scripts/xdg-file-dialog.in
index 0db2672..9c26681 100644
--- a/scripts/xdg-file-dialog.in
+++ b/scripts/xdg-file-dialog.in
@@ -31,8 +31,7 @@ _USAGE
open_kde()
{
- DIALOG=`command -v kdialog`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v kdialog`; then
if [ x"$TITLE" != x"" ]; then
$DIALOG --title "$TITLE" --getopenfilename "$1" ""
else
@@ -51,10 +50,9 @@ open_kde()
open_zenity()
{
- DIALOG=`command -v zenity`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v zenity`; then
if [ x"$1" != x"" ]; then
- cd `dirname "$1"` 2>/dev/null
+ cd "`dirname "$1"`" 2>/dev/null
FILENAME=`basename "$1"`
if [ x"$FILENAME" != x"" ]; then
FILENAME="--filename=""$FILENAME"
@@ -87,8 +85,7 @@ open_zenity()
open_multi_kde()
{
- DIALOG=`command -v kdialog`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v kdialog`; then
if [ x"$TITLE" != x"" ]; then
$DIALOG --title "$TITLE" --multiple --separate-output \
--getopenfilename "$1" ""
@@ -108,10 +105,9 @@ open_multi_kde()
open_multi_zenity()
{
- DIALOG=`command -v zenity`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v zenity`; then
if [ x"$1" != x"" ]; then
- cd `dirname "$1"` 2>/dev/null
+ cd "`dirname "$1"`" 2>/dev/null
FILENAME=`basename "$1"`
if [ x"$FILENAME" != x"" ]; then
FILENAME="--filename=""$FILENAME"
@@ -145,8 +141,7 @@ open_multi_zenity()
save_kde()
{
- DIALOG=`command -v kdialog`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v kdialog`; then
if [ x"$TITLE" != x"" ]; then
$DIALOG --title "$TITLE" --getsavefilename "$1" ""
else
@@ -165,10 +160,9 @@ save_kde()
save_zenity()
{
- DIALOG=`command -v zenity`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v zenity`; then
if [ x"$1" != x"" ]; then
- cd `dirname "$1"` 2>/dev/null
+ cd "`dirname "$1"`" 2>/dev/null
FILENAME=`basename "$1"`
if [ x"$FILENAME" != x"" ]; then
FILENAME="--filename=""$FILENAME"
@@ -201,8 +195,7 @@ save_zenity()
directory_kde()
{
- DIALOG=`command -v kdialog`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v kdialog`; then
if [ x"$TITLE" != x"" ]; then
$DIALOG --title "$TITLE" --getexistingdirectory "$1" ""
else
@@ -221,8 +214,7 @@ directory_kde()
directory_zenity()
{
- DIALOG=`command -v zenity`
- if [ $? -eq 0 ]; then
+ if DIALOG=`command -v zenity`; then
if [ x"$1" != x"" ]; then
cd "$1" 2>/dev/null
fi
diff --git a/scripts/xdg-icon-resource.in b/scripts/xdg-icon-resource.in
index 5647a96..ac17ae6 100644
--- a/scripts/xdg-icon-resource.in
+++ b/scripts/xdg-icon-resource.in
@@ -386,7 +386,7 @@ need_gnome_mime=
[ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-z]$//'`
-if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
+if [ "$vendor" = "true" ] && [ "$action" = "install" ] && [ "$context" = "apps" ] ; then
check_vendor_prefix "$icon_name" "icon name"
fi
@@ -397,7 +397,7 @@ DEBUG 1 "$action icon in $xdg_dir"
[ "$action" = "install" ] && [ -f "$icon_icon_file" ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir"
[ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
[ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)"
-[ "$action" = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
+[ "$action" = "install" ] && [ -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
case "$action" in
install)
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
index 9bb047e..97e7368 100644
--- a/scripts/xdg-mime.in
+++ b/scripts/xdg-mime.in
@@ -347,7 +347,7 @@ defapp_fallback()
done
if [ -n "$desktop_file" ] ; then
- echo `basename $desktop_file`
+ basename $desktop_file
exit_success
fi
}
@@ -361,7 +361,7 @@ check_mimeapps_list()
for desktop in $XDG_CURRENT_DESKTOP ''; do
IFS="$oldifs"
if [ -n "$desktop" ]; then
- local prefix=$(echo "$desktop-" | tr '[:upper:]' '[:lower:]')
+ local prefix="$(echo "$desktop-" | tr '[:upper:]' '[:lower:]')"
else
local prefix=
fi
@@ -619,7 +619,7 @@ fi
if [ "$action" = "defapp" ]; then
detectDE
- if [ "$DE" == "kde" ] && [ "$KDE_SESSION_VERSION" -lt "6" ]; then
+ if [ "$DE" = "kde" ] && [ "$KDE_SESSION_VERSION" -lt "6" ]; then
defapp_kde "$mimetype"
fi
@@ -686,7 +686,7 @@ if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
fi
if [ -z "$mode" ] ; then
- if [ `whoami` = "root" ] ; then
+ if [ "`id -u`" -eq 0 ] ; then
mode="system"
else
mode="user"
@@ -697,7 +697,7 @@ if [ -z "$filename" ] ; then
exit_failure_syntax "mimetypes-file argument missing"
fi
-if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+if [ "$vendor" = "true" ] && [ "$action" = "install" ] ; then
check_vendor_prefix "$filename"
fi
@@ -833,7 +833,7 @@ case $action in
# No quotes around $mimetypes
for x in $mimetypes ; do
DEBUG 1 "Installing $kde_dir/$x.desktop (KDE 3.x support)"
- mkdir -p `dirname $kde_dir/$x.desktop`
+ mkdir -p "`dirname $kde_dir/$x.desktop`"
awk < "$filename" '
# Strip XML comments
BEGIN {
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index 1b74e84..1f925da 100755
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -97,7 +97,7 @@ file_url_to_path()
get_hostname
if echo "$file" | grep -q '^file://'; then
file=${file#file://localhost}
- file=${file#file://$HOSTNAME}
+ file=${file#file://"$HOSTNAME"}
file=${file#file://}
if ! echo "$file" | grep -q '^/'; then
echo "$file"
@@ -394,7 +394,7 @@ open_generic_xdg_file_mime()
open_generic_xdg_x_scheme_handler()
{
scheme="`echo $1 | sed -n 's/\(^[[:alnum:]+\.-]*\):.*$/\1/p'`"
- if [ -n $scheme ]; then
+ if [ -n "$scheme" ]; then
filetype="x-scheme-handler/$scheme"
open_generic_xdg_mime "$1" "$filetype"
fi
diff --git a/scripts/xdg-screensaver.in b/scripts/xdg-screensaver.in
index 3ef039b..eb1b698 100644
--- a/scripts/xdg-screensaver.in
+++ b/scripts/xdg-screensaver.in
@@ -36,7 +36,7 @@ else
# No secure moves available, use home dir
DEBUG 1 "mv -T not available"
MV="mv"
- screensaver_file="$HOME/.xdg-screensaver-"`echo $(hostname)-$DISPLAY | sed 's/:/-/g'`
+ screensaver_file="$HOME/.xdg-screensaver-"`echo "$(hostname)"-$DISPLAY | sed 's/:/-/g'`
fi
lockfile_command=`command -v lockfile`
@@ -128,7 +128,7 @@ perform_action()
;;
esac
- if [ -n "$DISPLAY" -a "$1" = "suspend" ] ; then
+ if [ -n "$DISPLAY" ] && [ "$1" = "suspend" ] ; then
# Save DPMS state
if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
test "${TMPDIR+set}" = set || TMPDIR=/tmp
@@ -294,7 +294,7 @@ screensaver_freedesktop()
status=`echo "$raw_status" | grep boolean | cut -d ' ' -f 5`
result=$?
fi
- if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
+ if [ x"$status" = "xtrue" ] || [ x"$status" = "xfalse" ]; then
echo "enabled"
elif [ x"$result" != "x0" ]; then
echo "ERROR: dbus org.freedesktop.ScreenSaver.GetActive returned '$status'" >&2
@@ -555,7 +555,7 @@ screensaver_gnome_screensaver()
org.gnome.ScreenSaver.GetActive \
| grep boolean | cut -d ' ' -f 5`
result=$?
- if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
+ if [ x"$status" = "xtrue" ] || [ x"$status" = "xfalse" ]; then
echo "enabled"
elif [ x"$result" != "x0" ]; then
echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
@@ -631,7 +631,7 @@ screensaver_mate_screensaver()
org.mate.ScreenSaver.GetActive \
| grep boolean | cut -d ' ' -f 5`
result=$?
- if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
+ if [ x"$status" = "xtrue" ] || [ x"$status" = "xfalse" ]; then
echo "enabled"
elif [ x"$result" != "x0" ]; then
echo "ERROR: dbus org.mate.ScreenSaver.GetActive returned '$status'" >&2
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
index 4276b05..40f739e 100755
--- a/scripts/xdg-settings.in
+++ b/scripts/xdg-settings.in
@@ -98,7 +98,7 @@ xdg_mime_fixup()
# further processes need it around. But since it does not close its stdout,
# the shell (via grep) will wait around for kdeinit to exit. If we start a
# copy here, that copy will be used in xdg-mime and we will avoid waiting.
- if [ "$DE" = kde -a -z "$XDG_MIME_FIXED" ]; then
+ if [ "$DE" = kde ] && [ -z "$XDG_MIME_FIXED" ]; then
ktradertest text/html Application > /dev/null 2>&1
# Only do this once, as we only need it once.
XDG_MIME_FIXED=yes
@@ -236,15 +236,15 @@ check_browser_kde()
binary="`resolve_kde_browser`"
# The browser may contain a relative entry to the binary starting with !
- if [ x"!" = x"$(printf %.1s "$browser")" ]; then
+ case "$browser" in !*)
# get the full path
- browser="`binary_to_desktop_file ${browser:1}`"
+ browser="`binary_to_desktop_file ${browser#!}`"
binary="`desktop_file_to_binary $browser`"
- fi
+ esac
# Because KDE will use the handler for MIME type text/html if this value
# is empty, we allow either the empty string or a match to $check here.
- if [ x"$binary" != x -a x"$binary" != x"$check" ]; then
+ if [ x"$binary" != x ] && [ x"$binary" != x"$check" ]; then
echo no
exit_success
fi
@@ -494,7 +494,7 @@ get_browser_generic()
if [ -n "$BROWSER" ]; then
local browser=$(binary_to_desktop_file "${BROWSER%%:*}")
if [ -n "$browser" ]; then
- echo "$(basename "$browser")"
+ basename "$browser"
return 0
fi
fi
@@ -506,7 +506,7 @@ get_browser_generic()
# Debian and derivatives have x-www-browser
local browser=$(binary_to_desktop_file x-www-browser)
if [ -n "$browser" ]; then
- echo "$(basename "$browser")"
+ basename "$browser"
return 0
fi
@@ -597,14 +597,14 @@ check_url_scheme_handler_kde()
echo no
exit_success
fi
- if [ x"$1" = "mailto" ]; then
+ if [ "$1" = "mailto" ]; then
binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`"
# The field may contain a relative entry to the binary starting with !
- if [ x"!" = x"$(printf %.1s "$binary")" ]; then
+ case "$browser" in !*)
# get the full path
- desktop_file="`binary_to_desktop_file ${binary:1}`"
+ desktop_file="`binary_to_desktop_file ${binary#!}`"
binary="`desktop_file_to_binary $desktop_file`"
- fi
+ esac
if [ x"$binary" != x"$check" ]; then
echo no
exit_success
@@ -851,13 +851,13 @@ fi
[ x"$1" != x ] || exit_failure_syntax "no operation given"
[ x"$2" != x ] || exit_failure_syntax "no parameter name given"
-[ x"$1" = x"get" -o x"$3" != x ] || exit_failure_syntax "no parameter value given"
+[ x"$1" = x"get" ] || [ x"$3" != x ] || exit_failure_syntax "no parameter value given"
op="$1"
parm="$2"
shift 2
-if [ x"$op" != x"get" -a x"$op" != x"check" -a x"$op" != x"set" ]; then
+if [ x"$op" != x"get" ] && [ x"$op" != x"check" ] && [ x"$op" != x"set" ]; then
exit_failure_syntax "invalid operation"
fi
diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in
index dc737e9..14259c6 100644
--- a/scripts/xdg-utils-common.in
+++ b/scripts/xdg-utils-common.in
@@ -41,7 +41,7 @@ binary_to_desktop_file()
command="`command -v "$command"`"
if [ x"`readlink -f "$command"`" = x"$binary" ]; then
# Fix any double slashes that got added path composition
- echo "$file" | sed -e 's,//*,/,g'
+ echo "$file" | tr -s /
return
fi
done
@@ -314,7 +314,7 @@ detectDE()
if [ x"$KDE_FULL_SESSION" != x"" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate;
- elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
+ elif dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1 ; then DE=gnome;
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce
elif echo $DESKTOP | grep -q '^Enlightenment'; then DE=enlightenment;