From owner-freebsd-current@freebsd.org Fri Jul 3 15:58:34 2020 Return-Path: Delivered-To: freebsd-current@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 129D335242A for ; Fri, 3 Jul 2020 15:58:34 +0000 (UTC) (envelope-from se@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49z04T6lD2z4RJj; Fri, 3 Jul 2020 15:58:33 +0000 (UTC) (envelope-from se@freebsd.org) Received: from Stefans-MacBook-Pro-449.fritz.box (p200300cd5f2033002024905b0514c3cf.dip0.t-ipconnect.de [IPv6:2003:cd:5f20:3300:2024:905b:514:c3cf]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 3752E22F1C; Fri, 3 Jul 2020 15:58:33 +0000 (UTC) (envelope-from se@freebsd.org) Subject: Re: CURRENT: bc -e results in empty string/result To: "O. Hartmann" , FreeBSD CURRENT References: <20200703172503.5b739102@thor.intern.walstatt.dynvpn.de> From: =?UTF-8?Q?Stefan_E=c3=9fer?= Autocrypt: addr=se@freebsd.org; keydata= mQENBFVxiRIBCADOLNOZBsqlplHUQ3tG782FNtVT33rQli9EjNt2fhFERHIo4NxHlWBpHLnU b0s4L/eItx7au0i7Gegv01A9LUMwOnAc9EFAm4EW3Wmoa6MYrcP7xDClohg/Y69f7SNpEs3x YATBy+L6NzWZbJjZXD4vqPgZSDuMcLU7BEdJf0f+6h1BJPnGuwHpsSdn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0frte9a/fVEBQJa8u+rBQkL JQEZAAoJEEfrte9a/fVEuesH/2DNxGWnHvWwMyiyhlQtafvDKwEn/wAgR8gHJFodB7emf8rA TnukH7MVttCoHtjN5lvv9RSBHjNTZls5wR/ANlwdRuPQHd8ZGxLe3S6IuUB3zDSwFltLGurO N2kOMhs5mTGyypSa+uw3rtQbUAVYf1oPbiR4FLtiM8FLyEvE95hX5fPq9Qvx9FmN79kmCIEw jDKPqDaUf/OR2fEF0LSIbXHEk4tNqCEwx5DIJ0fp5/z5UzICUAmwxyRs5O/Hre1jzPsMVyud Ml9t7UTOJGKVWwRory1PMnOFxN+iz5/d4FhYSKXF7kfMiFgol4LuWaxJRwbBrr71VGBrRy2a L1nw6Bc= Message-ID: <82c80079-2e33-dfea-4553-37806c6fbe60@freebsd.org> Date: Fri, 3 Jul 2020 17:58:27 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200703172503.5b739102@thor.intern.walstatt.dynvpn.de> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jul 2020 15:58:34 -0000 Am 03.07.20 um 17:24 schrieb O. Hartmann: > Hello list, > > running some scripts caluclating via bc() the expression shown below: > > bc -e '6582031 - 1048576 - 0 - 409600 - 1024 - 40 - 4096' -e quit The bc in -CURRENT has been replaced by a new implementation. It seems there is one deviation from the behavior of the "old" version, in that it executes the "quit" immediately after parsing it. There is a difference between "quit" and "halt", and the following command works as expected: $ bc -e '6582031 - 1048576 - 0 - 409600 - 1024 - 40 - 4096' -e halt 5118695 >From the bc man-page: The quit statement causes bc(1) to quit, even if it is on a branch that will not be executed (it is a compile-time command). The halt statement causes bc(1) to quit, if it is executed. (Unlike quit if it is on a branch of an if statement that is not executed, bc(1) does not quit.) This behavior is identical to that of GNU bc: $ echo "6582031 - 1048576 - 0 - 409600 - 1024 - 40 - 4096; quit " | gbc $ echo "6582031 - 1048576 - 0 - 409600 - 1024 - 40 - 4096; halt " | gbc 5118695 > results on recent CURRENT ( FreeBSD 13.0-CURRENT #80 r362884: Thu Jul 2 10:08:23 CEST 2020 > amd64) with an empty result, while it is calculated correctly on 12-STABLE (FreeBSD > 12.1-STABLE #67 r362719: Sun Jun 28 09:59:20 CEST 2020 amd64) and a CURRENT dated from Sun > Jun 28th (have no revision number anymore, the expression above was calculated correctly on > the same box which now has r362884 and is failing). > > Whats wrong? The behavior of the "old" bc in FreeBSD was non-conformant in several details, the result of a modulo operation with negative operands was the most critical, in my opinion. This is what POSIX says with regard to the "quit" command: The quit statement ( quit) shall stop execution of a bc program at the point where the statement occurs in the input, even if it occurs in a function definition, or in an if, for, or while statement. But I'm not sure whether this covers the behavior of GNU bc and this new bc, since it does not say, that "quit" will be executed as soon as seen by the parser. Regards, STefan