NetBSD Problem Report #57670

From kre@munnari.OZ.AU  Thu Oct 19 17:44:16 2023
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 14A911A9238
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 19 Oct 2023 17:44:16 +0000 (UTC)
Message-Id: <202310191744.39JHi63f025414@jacaranda.noi.kre.to>
Date: Fri, 20 Oct 2023 00:44:06 +0700 (+07)
From: kre@munnari.OZ.AU
To: gnats-bugs@NetBSD.org
Subject: expr(1) man page contains a particularly useless example
X-Send-Pr-Version: 3.95

>Number:         57670
>Category:       bin
>Synopsis:       expr(1) man page contains a particularly useless example
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 19 17:45:00 +0000 2023
>Originator:     Robert Elz
>Release:        NetBSD 10.99.10
>Organization:
>Environment:
System: NetBSD jacaranda.noi.kre.to 10.99.10 NetBSD 10.99.10 (JACARANDA:1.1-20231005) #108: Fri Oct 6 03:19:02 +07 2023 kre@jacaranda.noi.kre.to:/usr/obj/testing/kernels/amd64/JACARANDA amd64
Architecture: x86_64
Machine: amd64
>Description:
	In the EXAMPLES section of expr(1) the following is given as one of the
	examples...

	     2.   The following example returns zero, due to subtraction having higher
	          precedence than the “&” operator:
		       expr 1 '&' 1 - 1

	That's bizarre, the precedence of the operators is irrelevant here (what it
	says is correct, but pointless)

		1 & (1 - 1)	== 0   (1 & 0 == 0)
		(1 & 1) - 1	== 0   (1 - 1 == 0)

	If the man page is to have an example to illustrate that operator precedence
	matters, it should be giving an example where it really does make a differemce.

	Perhaps

		expr 1 '|' 2 - 1

	where 1 | (2 - 1)  (the actual answer) == 1 (1 | 1 == 1) but
	where (1 | 2) - 1  (incorrect precedence) == 2  (3 - 1 == 2).

>How-To-Repeat:
	RTFM.
>Fix:
	Use a better example.   Or simply delete that one.

	And since -10 is still in beta, perhaps pull up the fix to that,
	so we don't have to go another decade or so before we have a
	release containn sanity.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.