summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorRodrigo Silva <gnome@rodrigosilva.com>2011-08-23 16:47:09 +0200
committerTomas Bzatek <tbzatek@redhat.com>2011-08-23 16:47:09 +0200
commitb76c3e8053a44b971c5fc8b6ff9d5adfb6557eb5 (patch)
tree6f3ea7df426e645fea7953e140bc8ae643e1e85d /programs
parentccf3f4de75742f7419a9289784e5421a4c838a8a (diff)
downloadgvfs-b76c3e8053a44b971c5fc8b6ff9d5adfb6557eb5.tar.gz
gvfs-open: Exit with error code > 0 when open fails
Previously gvfs-open exited with success (error code 0) even when open failed, either because file was not found or there was no default application registred to open it. Without easy testing for error codes, it was hard to use it in scripts. Now it exits with code 1 when any of the given files are either not found or its default application is not registered. https://bugzilla.gnome.org/show_bug.cgi?id=655470
Diffstat (limited to 'programs')
-rw-r--r--programs/gvfs-open.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/programs/gvfs-open.c b/programs/gvfs-open.c
index 7e197d81..c72a896a 100644
--- a/programs/gvfs-open.c
+++ b/programs/gvfs-open.c
@@ -47,7 +47,7 @@ is_file_uri_with_anchor (char *str)
return FALSE;
}
-static void
+static gboolean
open (GFile *file, char *arg_string)
{
GAppInfo *app;
@@ -65,7 +65,7 @@ open (GFile *file, char *arg_string)
g_printerr (_("%s: %s: error opening location: %s\n"),
g_get_prgname (), g_file_get_uri (file), error->message);
g_error_free (error);
- return;
+ return FALSE;
}
if (g_file_is_native (file) && !is_file_uri_with_anchor (arg_string))
@@ -96,7 +96,7 @@ open (GFile *file, char *arg_string)
g_object_unref (app);
- return;
+ return res;
}
int
@@ -107,6 +107,7 @@ main (int argc, char *argv[])
GFile *file;
gchar *summary;
int i;
+ gint res;
setlocale (LC_ALL, "");
@@ -157,14 +158,17 @@ main (int argc, char *argv[])
}
i = 0;
+ res = 0;
do
{
file = g_file_new_for_commandline_arg (locations[i]);
- open (file, locations[i]);
+ res += !open (file, locations[i]);
g_object_unref (file);
}
while (locations[++i] != NULL);
+ if (res)
+ return 2;
return 0;
}