From owner-freebsd-questions@freebsd.org Sun Sep 20 18:28:07 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B56BC3EA25B for ; Sun, 20 Sep 2020 18:28:07 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BvbfZ3SS9z3d2s for ; Sun, 20 Sep 2020 18:28:06 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([178.5.239.216]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPA (Nemesis) id 1Mzz6s-1keK0L0fwc-00x7P4; Sun, 20 Sep 2020 20:28:03 +0200 Date: Sun, 20 Sep 2020 20:28:02 +0200 From: Polytropon To: Michael Sierchio Cc: FreeBSD Questions Subject: Re: Error message output Message-Id: <20200920202802.a9e95f75.freebsd@edvax.de> In-Reply-To: References: <20200920191108.22864e5c.freebsd@edvax.de> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:AiJrftcoj29O9bYO0U8GQuM3Grv82ifyN9CKIFcfqVuHpuur4xl aT8jkufG1SBJX5JSwicOhL/ise1NWCo8UAqr1/IPccOLeO4K6NzT3EH6OXEiu0O/LWTuQaj ESLvXSzjz4NowPjDDFmC/RWTNqWiaORAk6LAGuJdvH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d.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.131) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [2.23 / 15.00]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; RCVD_VIA_SMTP_AUTH(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.35)[-0.355]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_PBL(0.00)[178.5.239.216:received]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.58)[-0.577]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.77)[0.766]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[212.227.126.131:from]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.227.126.131:from]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2020 18:28:07 -0000 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, ...