summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Puppe <dev@mpuppe.de>2019-04-13 12:46:44 +0200
committerMartin Puppe <dev@mpuppe.de>2019-04-13 12:46:44 +0200
commit0547886c0a7ae79145998495a6e3af6a1450d0c7 (patch)
tree4e0ee0d42f928c944cda8c562b9071eced0b1969
parentbfcefa162b1dcd6d62e193019969ff2f5ff331cf (diff)
xdg-mime: return correct exit code for GNOME
If the desktop environment was GNOME and none of the commands for detecting the MIME type of a file was available, xdg-mime used to return exit code 0 even though it failed. The man page says it should return exit code 3. This commit fixes the issue. I have considered returning exit code 4 instead since that is what would be returned if info_kde() or info_generic() fail to find a tool for MIME type detection. But I have decided to implement the behavior as specified in the man page. The exit code of an if construct is 0 if no condition tested true [^1]. The author of the original code probably was not aware of this. [^1]: https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs
-rw-r--r--scripts/xdg-mime.in2
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
index 0e567c7..034d0ef 100644
--- a/scripts/xdg-mime.in
+++ b/scripts/xdg-mime.in
@@ -84,6 +84,8 @@ info_gnome()
elif gnomevfs-info --help 2>/dev/null 1>&2; then
DEBUG 1 "Running gnomevfs-info \"$1\""
gnomevfs-info --slow-mime "$1" 2> /dev/null | grep "^MIME" | cut -d ":" -f 2 | sed s/"^ "//
+ else
+ exit_failure_operation_impossible "no method available for querying MIME type of '$filename'"
fi
if [ $? -eq 0 ]; then