[gvfs] Correct return values on error for programs
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] Correct return values on error for programs
- Date: Fri, 5 Mar 2010 16:12:46 +0000 (UTC)
commit 96e9f4b30cb9b4c70f4217f30a0d56a5747d7619
Author: Bastien Nocera <hadess hadess net>
Date: Fri Mar 5 11:26:24 2010 +0000
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(-)
---
diff --git a/programs/gvfs-copy.c b/programs/gvfs-copy.c
index 6d6ccc0..90b8821 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 0359172..9c8ac2d 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 7d7114b..97e92c6 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 94933b2..51cdb58 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 85f4fa0..52af8cc 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 d8689a4..e745319 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]