From owner-freebsd-bugs@freebsd.org Sun Mar 1 23:06:26 2020 Return-Path: Delivered-To: freebsd-bugs@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 E331F2514C6 for ; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 48VzRQ5ps9z49Py for ; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id C77EF2514C5; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) Delivered-To: bugs@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 C74102514C4 for ; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48VzRQ4hWJz49Pw for ; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 802C9B0C0 for ; Sun, 1 Mar 2020 23:06:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 021N6QLx067045 for ; Sun, 1 Mar 2020 23:06:26 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 021N6QD7067044 for bugs@FreeBSD.org; Sun, 1 Mar 2020 23:06:26 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 235589] sh(1): LINENO is unset in shell arithmetic Date: Sun, 01 Mar 2020 23:06:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.0-STABLE X-Bugzilla-Keywords: needs-qa X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jilles@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: jilles@FreeBSD.org X-Bugzilla-Flags: mfc-stable12? mfc-stable11? X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Mar 2020 23:06:26 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235589 --- Comment #6 from Jilles Tjoelker --- This is quite nice, but please run the tests (basically, cd /usr/tests/bin/= sh && kyua test) and add new tests for $((LINENO)). Existing tests should not = be modified unless they were broken or too specific. I think NCASE and NFOR nodes should also contain a line number. An earlier version of the patch did a simple 32-bit integer write during execution, leaving the snprintf(..., "%d", ...) to when LINENO was expanded= . I liked that better. There could be a VLINENO flag indicating LINENO's struct= var (and that it is still special, see below). Making LINENO readonly matches zsh but I found some obscure scripts searchi= ng for "LINENO=3D" on codesearch.debian.net (such as https://sources.debian.org/src/opentmpfiles/0.2+2019.05.21.git.44a55796ba-2= /tmpfiles.sh/?hl=3D443#L443 ) that assign values to LINENO and will then break. Currently, this is acce= pted but has almost no effect, so completely ignoring assignments is probably qu= ite safe. This also seems to happen in bash. In ksh variants, assigning to LINENO changes an offset for future LINENO expansions (for example, if line 10 contains LINENO=3D1010, future LINENO references will result in a line number 1000 more than normal; a bit like #= line in C). I suggest not implementing this because it will not work well with t= he current design for line numbers within functions. In both bash and ksh, unsetting LINENO makes it a normal variable, and the = only way to expand line numbers again is to restart the shell. Implementing this= may or may not be worth it. --=20 You are receiving this mail because: You are on the CC list for the bug.=