From owner-freebsd-questions@freebsd.org Sun Sep 20 17:11:13 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 78E683E7E68 for ; Sun, 20 Sep 2020 17:11:13 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) (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 4BvYxr1DcKz3YNB for ; Sun, 20 Sep 2020 17:11:11 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([178.5.239.216]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPA (Nemesis) id 1N14xe-1kUSEZ1Az4-012Xb0 for ; Sun, 20 Sep 2020 19:11:09 +0200 Date: Sun, 20 Sep 2020 19:11:08 +0200 From: Polytropon To: FreeBSD Questions Subject: Error message output Message-Id: <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:jMNhP4bus/ltHMO3R3ZzDTvjtCO/4n+Lzwpp+3o009YeYMfua1B 7h7Rwv51zlsKTFEcki7iNNn7B5LSFAb96lFbjbUwmljyHBpN/eMmro8eCu37kC4B/mwKe3b PbXoCNp0+JnGYD+zvzGZAW4vziiUJPPlomfWiPzFSEE14lY64NVtOg5x7IETaSa0uNUfSA4 eL8FjIQ1Sj3Gz5kzarZIA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:87fnvYrQl4o=:3DSG20DJgnaecQRQ1TJsm6 mcXqItybG//FyeMhOXCnp/+7I2+rsCdmNMzXezqq/xRK9xa4zg+vMHxkafw5XFnBWV14rrQgB mm0PSQZzNEWd3Dj/CGGuakTTtAUi6u1V54dR+EyB/7AtS9TlcbAYMmDq1BHx1+wNIlmzn8PWu Tw8/wWsVBcY3dXcRvvAthzjft9mKk1+yajXuhSq7JK9ZQtI6cZgxoSalPhi8PThxL1c+mfaPz jzdv0Cbk3lmxVICJdkJfxujYOC4V0ceu1/esFpVmGRR4p8fgRm3zRRNcLKxDvG6OTP6YTvAnu PqLbvYUj24dXrhyIuOlPghHkLkAKzz6witECrQbNxBvAq3nwN27KpbuPPsEW4GuTpo8uvMTpk o54hg45m5T9OGCXanPkJMUuh79+FkckAdZ1yU+KihQxY0cpSYg9L0fMq7fiv+ZjLohpCJzG1I S9YdX3HUEpdtrNUDOeUevyZV4YgASsTwmuW8FdF17TTtNkihXnCDTYik4E+pvo7NUki2s7kV3 R8g5g76GBR2pPOWEDeMWusZ18KX1+P2l+EkLSD4rno26Iq6dwmjAqGSGnSJYymvJoNCpqJ2f4 cQwGeiq3LjzW0L8wK/RRW1ckvjwM9l8sWZ9vohpLfXFZ5hJz/L+YOJ2vexyuPhAa4mxUGTUTq zA59DRUTHKj7YZ7M8IS0++LvWPB10nnTgE+XJx4jB3jykJbfRdVi+0Gw1luQiheLOxoDxKTCe fK57hK7ASIONUnsLklpFrGd4DmbXWR0l0VUbC6nxzknMkevSdaKTm5y/Co8ndk5/qWRNm3aCh T60qSPNbs1Zxant50Bg8W3d2fmtSkE9Fhj04gs4haTYbEcXlB7acNkv0g6gNRxRskbTidRK X-Rspamd-Queue-Id: 4BvYxr1DcKz3YNB X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.134) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [3.55 / 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)[]; RECEIVED_SPAMHAUS_PBL(0.00)[178.5.239.216:received]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(0.02)[0.022]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_SPAM_MEDIUM(0.15)[0.151]; RCVD_TLS_LAST(0.00)[]; NEURAL_SPAM_LONG(0.98)[0.980]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[212.227.126.134:from]; R_SPF_NA(0.00)[no SPF record]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.227.126.134: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 17:11:13 -0000 I have a general question. Is it still considered useful to output error messages of a script to standard error? Example: if [ something not okay ]; then echo "the error message" > /dev/stderr exit 1 fi While progress messages will per default go to standard output, error messages should be printed to standard error. The reason: If a program is silenced to > /dev/null, error messages will still be visible (no "silent failing"); if a user wants to explicitely mute all messages, > /dev/null 2>&1 has to be specified for the redirection. The judgement if a message is a regular progress message, an information about some slightly problematic case, or a real fatal error depends on the programmer. For example: echo "${FILE] processed, ${RECS} records counted." -> standard output echo "${DIR} already checked, skipping." -> standard output (non-fatal error" echo "${DEV} is read only, aborting." exit 1 -> standard error (fatal error) echo "Cannot start: Input filename missing." usage() exit 1 -> standard error (fatal error) At least that's what I've learned centuries ago. Is that still valid? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...