[rrd-users] rrdtool 1.0.49 return error code
Haroon Rafique
haroon.rafique at utoronto.ca
Fri Oct 1 17:15:48 MEST 2004
Hi listers,
I have a question regarding return codes from rrdtool 1.0.49.
If I execute:
rrdtool update /blah/nonexistent/file/path
Shouldn't the value of $? afterwards be non-zero.
Here's what I get when executing:
prompt$ rrdtool update /blah/nonexistent/file/path; echo $?
ERROR: Not enough arguments
0
Basically, I'm implying that the error handling from the rrd_*.c files
should sort of bubble up so that the main program can return a non-zero
error code. Would be a useful feature when running the updates via shells
to look for errors.
The following diff seems to work for me.
--- src/rrd_tool.c.orig 2004-08-08 06:58:14.000000000 -0400
+++ src/rrd_tool.c 2004-10-01 11:08:51.389447262 -0400
@@ -263,8 +263,11 @@
PrintUsage(argv[1]);
exit(0);
}
- else
- HandleInputLine(argc, argv, stderr);
+ else {
+ if(HandleInputLine(argc, argv, stderr)) {
+ return 1;
+ }
+ }
return 0;
}
@@ -426,6 +429,7 @@
if (rrd_test_error()) {
fprintf(out, "ERROR: %s\n",rrd_get_error());
rrd_clear_error();
+ return 1;
}
return(0);
}
The tabbing is a mish-mash in the original file, so for this tiny patch,
you might wanna just apply it by hand.
After applying the above diff, and executing the command, gives me:
rrdtool update /path/to/nonexistent/file; echo $?
ERROR: Not enough arguments
1
Hopefully this will get adopted into the main branch if people find it
useful.
Regards,
--
Haroon Rafique
<haroon.rafique at utoronto.ca>
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list