From owner-freebsd-bugs@freebsd.org Sun Sep 8 21:29:43 2019 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 272DCE39C0 for ; Sun, 8 Sep 2019 21:29:43 +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 46RPZb0GV9z48LR for ; Sun, 8 Sep 2019 21:29:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 0753FE39BF; Sun, 8 Sep 2019 21:29:43 +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 07174E39BE for ; Sun, 8 Sep 2019 21:29:43 +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 46RPZZ6MfKz48LQ for ; Sun, 8 Sep 2019 21:29:42 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB286333A for ; Sun, 8 Sep 2019 21:29:42 +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 x88LTgCk088711 for ; Sun, 8 Sep 2019 21:29:42 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x88LTgL5088710 for bugs@FreeBSD.org; Sun, 8 Sep 2019 21:29:42 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, 08 Sep 2019 21:29:42 +0000 X-Bugzilla-Reason: AssignedTo 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: bugs@FreeBSD.org X-Bugzilla-Flags: mfc-stable11? mfc-stable12? 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, 08 Sep 2019 21:29:43 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235589 --- Comment #3 from Jilles Tjoelker --- I like that this does not slow down the main execution loop much, since it = only does the conversion from integer to string when LINENO is referenced. This part could be slightly less magic by making a fixed struct var for LIN= ENO (like HISTSIZE, IFS, MAIL, MAILPATH, etc.). This fixed struct can also poin= t to a sufficiently large buffer "LINENO=3D1\0\0\0\0\0\0\0\0\0\0". I would like to see this new mechanism used instead of the old VSLINENO mechanism (so there aren't two separate mechanisms for $LINENO and $((LINENO))). Given that this will subtly change LINENO values anyway (try expanding LINE= NO twice in different lines of a word spanning multiple lines), I think it wou= ld make more sense to make it more like other shells do, reading the line numb= er at the start of a command containing expansions (NCMD/NCASE/NFOR). With this, it should be possible to set PS4=3D'$LINENO+ ' and see the scrip= t's line numbers in set -x output. You can compare https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=3D5bb39bb1995= cb12d8da76b1d482df9be1acc2eb4 which is a similar implementation for dash (another Almquist variant) but I don't think there will be much benefit in copying code from there. --=20 You are receiving this mail because: You are the assignee for the bug.=