Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Sep 2020 20:28:02 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Michael Sierchio <kudzu@tenebras.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Error message output
Message-ID:  <20200920202802.a9e95f75.freebsd@edvax.de>
In-Reply-To: <CAHu1Y73Wsceqt=c1__UtAdcR9qU9tc6ZH57F-Zc0DGVwJwiKrA@mail.gmail.com>
References:  <20200920191108.22864e5c.freebsd@edvax.de> <CAHu1Y73Wsceqt=c1__UtAdcR9qU9tc6ZH57F-Zc0DGVwJwiKrA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 20 Sep 2020 11:19:32 -0700, Michael Sierchio wrote:
> If you know something about the error, don't just exit with any return
> value.
> 
> *>* man sysexits

Yes, I know about that (and I tend to use it in C programs);
my examples simply contained "exit 1" as opposed to explicit
or implicit "exit 0" to _at least_ signal to the caller that
there was some error. Of course being specific with an error
code from sysexits, especially using the nice EX_* values,
is convenient from C code, but requires looking them up in
the manual in case of a sh script. :-)

I fully agree that there is nothing wrong with something
like:

	if [ "$1" = "" ]; then
		echo "Error: Missing filename." > /dev/stderr
		exit 64
	fi

For C code, there are also the values EXIT_SUCCESS and
EXIT_FAILURE in stdlib.h with values 0 and 1 respectively,
in case sysexits.h should not be available.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200920202802.a9e95f75.freebsd>