# HG changeset patch # User John W. Eaton # Date 1626976369 14400 # Node ID 0f41e117789f348ac0d935d235b02bd7c04e47a4 # Parent 3583b11e151b8d80205583cc4ed8929abfdfe34c disable getopt error reporting in wrapper program (bug #60886) * getopt-wrapper.h, getopt-wrapper.c (octave_get_opterr_wrapper, octave_set_opterr_wrapper): New functions. * main.in.cc (main): Call octave_set_opterr_wrapper to disable getopt error reporting. diff -r 3583b11e151b -r 0f41e117789f liboctave/wrappers/getopt-wrapper.c --- a/liboctave/wrappers/getopt-wrapper.c Thu Jul 22 19:04:52 2021 +0200 +++ b/liboctave/wrappers/getopt-wrapper.c Thu Jul 22 13:52:49 2021 -0400 @@ -121,3 +121,20 @@ { return optind; } + +int +octave_get_opterr_wrapper (void) +{ + return opterr; +} + +int +octave_set_opterr_wrapper (int val) +{ + int retval = opterr; + + opterr = val; + + return retval; +} + diff -r 3583b11e151b -r 0f41e117789f liboctave/wrappers/getopt-wrapper.h --- a/liboctave/wrappers/getopt-wrapper.h Thu Jul 22 19:04:52 2021 +0200 +++ b/liboctave/wrappers/getopt-wrapper.h Thu Jul 22 13:52:49 2021 -0400 @@ -52,6 +52,9 @@ extern int octave_optind_wrapper (void); +extern OCTAVE_API int octave_get_opterr_wrapper (void); +extern OCTAVE_API int octave_set_opterr_wrapper (int val); + #if defined __cplusplus } #endif diff -r 3583b11e151b -r 0f41e117789f src/main.in.cc --- a/src/main.in.cc Thu Jul 22 19:04:52 2021 +0200 +++ b/src/main.in.cc Thu Jul 22 13:52:49 2021 -0400 @@ -245,6 +245,13 @@ bool warn_display = true; bool no_display = false; + // Disable error reporting in getopt. We want to silently recognize + // and process a few special arguments here and pass everything on to + // the real Octave program where incorrect usage errors may be + // reported. + + octave_set_opterr_wrapper (0); + while (true) { int long_idx;