summaryrefslogtreecommitdiff
path: root/scripts/xdg-email.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2020-03-26 13:49:45 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-11-06 07:27:56 -0500
commit8ae02631a9806da11b34cd6b274af02d28aee5da (patch)
tree67b4fc1d5ca4bd9597b6692bca1d8f07dbbce2d6 /scripts/xdg-email.in
parent80d025ae9675da60b32d5fe43dde9f35ebbc3081 (diff)
Replace all remaining usage of non-portable 'which' with POSIX command -v
The "which" utility is not guaranteed to be installed, and if it is, its behavior is not portable. Conversely, the "command -v" shell builtin is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere. Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 12-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh. A side benefit of using the POSIX portable option is that it does not require an external disk executable to be forked. This therefore represents a mild speedup.
Diffstat (limited to 'scripts/xdg-email.in')
-rw-r--r--scripts/xdg-email.in8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
index 85cf90a..dfb4b83 100644
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -90,7 +90,7 @@ open_kde()
local kreadconfig=kreadconfig
fi
- if which $kreadconfig >/dev/null 2>&1; then
+ if command -v $kreadconfig >/dev/null; then
local profile=$($kreadconfig --file emaildefaults \
--group Defaults --key Profile)
if [ -n "$profile" ]; then
@@ -98,7 +98,7 @@ open_kde()
--group "PROFILE_$profile" \
--key EmailClient \
| cut -d ' ' -f 1)
- if [ -z "${client%%*.desktop}" ] && ! which "$client" >/dev/null 2>&1; then
+ if [ -z "${client%%*.desktop}" ] && ! command -v "$client" >/dev/null 2>&1; then
client=`desktop_file_to_binary "$client"`
fi
@@ -115,7 +115,7 @@ open_kde()
*) command=kde-open$KDE_SESSION_VERSION ;;
esac
- if which $command >/dev/null 2>&1; then
+ if command -v $command >/dev/null; then
DEBUG 1 "Running $command \"$1\""
if [ "$KDE_SESSION_VERSION" = 3 ]; then
# KDE3 uses locale's encoding when decoding the URI,
@@ -435,7 +435,7 @@ mailto=`echo "${mailto}"| sed 's/[?&]$//'`
# Shouldn't happen
[ x"${mailto}" != x"" ] || exit_failure_syntax
-if which @NAME@-hook.sh > /dev/null 2> /dev/null; then
+if command -v @NAME@-hook.sh > /dev/null; then
@NAME@-hook.sh "${mailto}"
if [ $? -eq 0 ]; then
exit_success