From 5edb7aabe4ffd8de40c74e044ec442cbeefabc4a Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Tue, 27 Apr 2010 15:22:48 -0500 Subject: [svn-r18642] Purpose: Fix for Bug 1793 - h5ls on a non-existent file gives 0 return code Description: After the fix, h5ls returns 1 (EXIT_FAILURE) if non-existent file is given. Tested: jam, amani, linew --- tools/h5ls/h5ls.c | 7 ++++++- tools/h5ls/testh5ls.sh.in | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index c969670..c6eee3f 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -2180,6 +2180,7 @@ main(int argc, const char *argv[]) static char root_name[] = "/"; char drivername[50]; const char *preferred_driver = NULL; + int err_openfile = 0; /* Initialize h5tools lib */ h5tools_init(); @@ -2405,6 +2406,7 @@ main(int argc, const char *argv[]) if(file < 0) { fprintf(stderr, "%s: unable to open file\n", argv[argno-1]); HDfree(fname); + err_openfile = 1; continue; } /* end if */ if(oname) { @@ -2478,6 +2480,9 @@ main(int argc, const char *argv[]) HDfree(elink_list.objs); } /* end while */ - leave(EXIT_SUCCESS); + if (err_openfile) + leave(EXIT_FAILURE); + else + leave(EXIT_SUCCESS); } /* end main() */ diff --git a/tools/h5ls/testh5ls.sh.in b/tools/h5ls/testh5ls.sh.in index ddb09b5..367e539 100644 --- a/tools/h5ls/testh5ls.sh.in +++ b/tools/h5ls/testh5ls.sh.in @@ -173,7 +173,7 @@ TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5 # tests for error handling. # test for non-existing file -TOOLTEST nosuchfile.ls 0 nosuchfile.h5 +TOOLTEST nosuchfile.ls 1 nosuchfile.h5 # test for variable length data types in verbose mode if test $WORDS_BIGENDIAN != "yes"; then -- cgit v0.12