From owner-freebsd-questions@freebsd.org Sun Sep 20 18:20:11 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 A8B5F3E9D10 for ; Sun, 20 Sep 2020 18:20:11 +0000 (UTC) (envelope-from kudzu@tenebras.com) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BvbTQ3Knlz3cRr for ; Sun, 20 Sep 2020 18:20:10 +0000 (UTC) (envelope-from kudzu@tenebras.com) Received: by mail-lf1-x136.google.com with SMTP id u8so11590366lff.1 for ; Sun, 20 Sep 2020 11:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenebras-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=U5m5Oo0AIIYsudcz7YiEL8F+bLvyqJ1E7I8Q0bYNJlQ=; b=pm5+XYo+UDf+pbm/9oAUj94f4JveVbciKASvyos7Jz6GQnup4n/3DNo+LqpaSyJSJd Llb7jZ1ORJkenklI+Ry0Xfl3Xz6qa7gyksP7Y/M4OyfPSuWZaiVdgvAbIzbW22zv2HHF TkxUg00QAAG93E+YbXwRdIr46DNlhdiQCSOxZtTu71eTnduI9YYwXkY2/VYmFDk4n5kf TUsQymNOM4pEbvGl57l+Oh/2nAJ1TiItzIJ4hiopaaKlPljwD8SFfwJxzFibY05dPEBX H5TFCfMlnZ6W/tmV9tUAPT9tJXufbK5NbhAM/pHpR0zk6BNtrvo8CXtUWVu8L7eDW6MX xpBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=U5m5Oo0AIIYsudcz7YiEL8F+bLvyqJ1E7I8Q0bYNJlQ=; b=RwqsTSE7CWBVWEkZ3lGq7PmyHbSAs3tGOLGf+dKoAW3sZwum4NHElJATLWrKXGmsFR w3CgxV7G+YJmN/Fpu7x7cr/W8XAPQR8iUNUN5s/9AATD635J0j0JCp3+VcBp+AH7qPHR aOF6oI5OyqpSawlx76OrF5aA0Mucy1rUI7o7Tz9NZgqEKdTQn5d59MckN4VKt4/EJUI2 8FbaK/wg6gxqeXT2hbILQbEBPKoYxvflPWn4RZGnnAzrBbH482TZ4CUyrgS3UIRtnCkg r7WzSyLSaFytISf9CtE4JBFZ+aGrK8pMvo7QojZ14Ts72bIRiZDoHblvt7ZcqcY2KOdr j20A== X-Gm-Message-State: AOAM530JTrYk53KXqeHBMx9YC978Qo84zAR2hXSpXQMcfSds1AYNAuyf qupZoXoV46ujvF7CdqEgLJuYfPlrOTkrcKQgY7GiAFO2/4c5RkLX X-Google-Smtp-Source: ABdhPJyszYNZH5uW9GbxUHaA0KnS9BlowC4aiwjTcQ5PdYz2zutHzv49cBqwuayFQjJh2n8PmwWLZWg98pXSs+PLRws= X-Received: by 2002:a19:c157:: with SMTP id r84mr13250132lff.34.1600626008332; Sun, 20 Sep 2020 11:20:08 -0700 (PDT) MIME-Version: 1.0 References: <20200920191108.22864e5c.freebsd@edvax.de> In-Reply-To: <20200920191108.22864e5c.freebsd@edvax.de> From: Michael Sierchio Date: Sun, 20 Sep 2020 11:19:32 -0700 Message-ID: Subject: Re: Error message output To: Polytropon Cc: FreeBSD Questions X-Rspamd-Queue-Id: 4BvbTQ3Knlz3cRr X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=tenebras-com.20150623.gappssmtp.com header.s=20150623 header.b=pm5+XYo+; dmarc=none; spf=none (mx1.freebsd.org: domain of kudzu@tenebras.com has no SPF policy when checking 2a00:1450:4864:20::136) smtp.mailfrom=kudzu@tenebras.com X-Spamd-Result: default: False [-2.87 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[tenebras-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-1.01)[-1.007]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.05)[-1.045]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[tenebras.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[tenebras-com.20150623.gappssmtp.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::136:from]; NEURAL_HAM_SHORT(-0.52)[-0.521]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.33 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:20:11 -0000 If you know something about the error, don't just exit with any return value. *>* man sysexits On Sun, Sep 20, 2020 at 10:11 AM Polytropon wrote: > 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, ... > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" > --=20 "Well," Brahm=C4=81 said, "even after ten thousand explanations, a fool is = no wiser, but an intelligent person requires only two thousand five hundred." - The Mah=C4=81bh=C4=81rata