Le Fri, Jun 02, 2023 at 10:59:04PM +0200, Rhialto a écrit : > On Wed 31 May 2023 at 00:18:26 +0700, Robert Elz wrote: > > Date: Tue, 30 May 2023 16:11:55 +0200 > > From: tlaro...@polynum.com > > Message-ID: <zhyek1xzzvzsu...@polynum.com> > > > > > > | -c check a config file (and does not execute). Returns 0 on > > success and > > | ENOENT or EINVAL on error. > > > > If you mean what that seems to say, then no. The check only part is fine, > > but functions can return ENOENT or EINVAL (or can return -1, or NULL, or > > something with one of those in errno) - programs do not exit with those > > values as the status (as their values aren't specified, it is possible > > that ENOENT%256 (or ENOENT&0xFF if you prefer) == 0. > > > > You can either just exit with status 1, or exit 1 for file open failed > > (which covers a whole range of errno values, not just ENOENT), and 2 > > for invalid contents if you prefer. But never use errno values as an > > exit parameter. > > There is <sysexits.h> which defines "Exit status codes for system > programs." EX_DATAERR could be appropriate for an invalid config file. >
Thanks for the info! I didn't know about this... -- Thierry Laronde <tlaronde +AT+ polynum +dot+ com> http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C