Skip to content

Commit

Permalink
triggers: Use command -v in preference to which
Browse files Browse the repository at this point in the history
which(1) is not standardized by POSIX, and has different implementations
and behaviour on different distributions. The behaviour and exit status
of command -v is standardized by POSIX, and in particular, checking its
exit status is an appropriate way to ask: if I called this command,
would it be found?

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv authored and alexlarsson committed Jan 25, 2022
1 parent 6fdc907 commit bb307a5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion triggers/desktop-database.trigger
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

if test \( -x "$(which update-desktop-database 2>/dev/null)" \) -a \( -d "$1/exports/share/applications" \); then
if command -v update-desktop-database >/dev/null && test -d "$1/exports/share/applications"; then
exec update-desktop-database -q "$1/exports/share/applications"
fi
2 changes: 1 addition & 1 deletion triggers/gtk-icon-cache.trigger
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

if test \( -x "$(which gtk-update-icon-cache 2>/dev/null)" \) -a \( -d "$1/exports/share/icons/hicolor" \); then
if command -v gtk-update-icon-cache >/dev/null && test -d "$1/exports/share/icons/hicolor"; then
cp /usr/share/icons/hicolor/index.theme "$1/exports/share/icons/hicolor/"
for dir in "$1"/exports/share/icons/*; do
if test -f "$dir/index.theme"; then
Expand Down
2 changes: 1 addition & 1 deletion triggers/mime-database.trigger
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

if test \( -x "$(which update-mime-database 2>/dev/null)" \) -a \( -d "$1/exports/share/mime/packages" \); then
if command -v update-mime-database >/dev/null && test -d "$1/exports/share/mime/packages"; then
exec update-mime-database "$1/exports/share/mime"
fi

0 comments on commit bb307a5

Please sign in to comment.