NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/57670: expr(1) man page contains a particularly useless example



>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@localhost:/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.



Home | Main Index | Thread Index | Old Index