From 96e9f4b30cb9b4c70f4217f30a0d56a5747d7619 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 5 Mar 2010 11:26:24 +0000 Subject: Correct return values on error for programs Most of those programs would return 0 even on error. They should instead return 1 when an error occurred. https://bugzilla.gnome.org/show_bug.cgi?id=611891 --- programs/gvfs-copy.c | 4 +++- programs/gvfs-mkdir.c | 5 ++++- programs/gvfs-move.c | 4 +++- programs/gvfs-rename.c | 4 +++- programs/gvfs-rm.c | 8 ++++++-- programs/gvfs-trash.c | 8 ++++++-- 6 files changed, 25 insertions(+), 8 deletions(-) (limited to 'programs') diff --git a/programs/gvfs-copy.c b/programs/gvfs-copy.c index 6d6ccc0f..90b8821a 100644 --- a/programs/gvfs-copy.c +++ b/programs/gvfs-copy.c @@ -105,6 +105,7 @@ main (int argc, char *argv[]) char *basename; int i; GFileCopyFlags flags; + int retval = 0; setlocale (LC_ALL, ""); @@ -205,6 +206,7 @@ main (int argc, char *argv[]) copy_failed: g_printerr (_("Error copying file %s: %s\n"), argv[i], error->message); g_error_free (error); + retval = 1; } } @@ -214,5 +216,5 @@ main (int argc, char *argv[]) g_object_unref (dest); - return 0; + return retval; } diff --git a/programs/gvfs-mkdir.c b/programs/gvfs-mkdir.c index 0359172d..9c8ac2dc 100644 --- a/programs/gvfs-mkdir.c +++ b/programs/gvfs-mkdir.c @@ -41,6 +41,7 @@ main (int argc, char *argv[]) GError *error; GOptionContext *context; GFile *file; + int retval = 0; setlocale (LC_ALL, ""); @@ -77,6 +78,7 @@ main (int argc, char *argv[]) { g_printerr (_("Error creating directory: %s\n"), error->message); g_error_free (error); + retval = 1; } } else @@ -85,11 +87,12 @@ main (int argc, char *argv[]) { g_printerr (_("Error creating directory: %s\n"), error->message); g_error_free (error); + retval = 1; } g_object_unref (file); } } } - return 0; + return retval; } diff --git a/programs/gvfs-move.c b/programs/gvfs-move.c index 7d7114be..97e92c66 100644 --- a/programs/gvfs-move.c +++ b/programs/gvfs-move.c @@ -93,6 +93,7 @@ main (int argc, char *argv[]) char *basename; int i; GFileCopyFlags flags; + int retval = 0; setlocale (LC_ALL, ""); @@ -187,6 +188,7 @@ main (int argc, char *argv[]) move_failed: g_printerr (_("Error moving file %s: %s\n"), argv[i], error->message); g_error_free (error); + retval = 1; } } @@ -196,5 +198,5 @@ main (int argc, char *argv[]) g_object_unref (dest); - return 0; + return retval; } diff --git a/programs/gvfs-rename.c b/programs/gvfs-rename.c index 94933b23..51cdb586 100644 --- a/programs/gvfs-rename.c +++ b/programs/gvfs-rename.c @@ -40,6 +40,7 @@ main (int argc, char *argv[]) GError *error; GFile *file; GFile *new_file; + int retval = 0; setlocale (LC_ALL, ""); @@ -67,6 +68,7 @@ main (int argc, char *argv[]) { g_printerr (_("Error: %s\n"), error->message); g_error_free (error); + retval = 1; } else { @@ -77,5 +79,5 @@ main (int argc, char *argv[]) } g_object_unref (file); - return 0; + return retval; } diff --git a/programs/gvfs-rm.c b/programs/gvfs-rm.c index 85f4fa04..52af8ccf 100644 --- a/programs/gvfs-rm.c +++ b/programs/gvfs-rm.c @@ -43,6 +43,7 @@ main (int argc, char *argv[]) GError *error; GOptionContext *context; GFile *file; + int retval = 0; setlocale (LC_ALL, ""); @@ -65,12 +66,15 @@ main (int argc, char *argv[]) { if (!force || !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - g_printerr ("Error deleting file: %s\n", error->message); + { + g_printerr ("Error deleting file: %s\n", error->message); + retval = 1; + } g_error_free (error); } g_object_unref (file); } } - return 0; + return retval; } diff --git a/programs/gvfs-trash.c b/programs/gvfs-trash.c index d8689a49..e745319e 100644 --- a/programs/gvfs-trash.c +++ b/programs/gvfs-trash.c @@ -42,6 +42,7 @@ main (int argc, char *argv[]) GError *error; GOptionContext *context; GFile *file; + int retval = 0; setlocale (LC_ALL, ""); @@ -64,12 +65,15 @@ main (int argc, char *argv[]) { if (!force || !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - g_printerr (_("Error trashing file: %s\n"), error->message); + { + g_printerr (_("Error trashing file: %s\n"), error->message); + retval = 1; + } g_error_free (error); } g_object_unref (file); } } - return 0; + return retval; } -- cgit v1.2.1