From owner-freebsd-hackers@freebsd.org Mon Jul 15 05:10:45 2019 Return-Path: Delivered-To: freebsd-hackers@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 BC724B0DC3 for ; Mon, 15 Jul 2019 05:10:45 +0000 (UTC) (envelope-from me@pacopascal.com) Received: from MTA-05-3.privateemail.com (mta-05-3.privateemail.com [68.65.122.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 78FA676C1B for ; Mon, 15 Jul 2019 05:10:44 +0000 (UTC) (envelope-from me@pacopascal.com) Received: from MTA-05.privateemail.com (localhost [127.0.0.1]) by MTA-05.privateemail.com (Postfix) with ESMTP id A48246006F for ; Mon, 15 Jul 2019 01:10:35 -0400 (EDT) Received: from gauss (unknown [10.20.151.209]) by MTA-05.privateemail.com (Postfix) with ESMTPA id 5438F60049 for ; Mon, 15 Jul 2019 05:10:35 +0000 (UTC) Date: Mon, 15 Jul 2019 01:10:33 -0400 From: Paco Pascal To: freebsd-hackers@freebsd.org Subject: What's the expected behavior of LINENO from /bin/sh? Message-ID: <20190715051033.GA2591@gauss> Mail-Followup-To: Paco Pascal , freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.12.0 (2019-05-25) X-Virus-Scanned: ClamAV using ClamSMTP X-Rspamd-Queue-Id: 78FA676C1B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of me@pacopascal.com designates 68.65.122.15 as permitted sender) smtp.mailfrom=me@pacopascal.com X-Spamd-Result: default: False [-2.17 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:68.65.122.0/27]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_NONE(0.00)[]; MX_GOOD(-0.01)[mx1.privateemail.com]; NEURAL_HAM_SHORT(-0.67)[-0.665,0]; RCVD_IN_DNSWL_NONE(0.00)[15.122.65.68.list.dnswl.org : 127.0.5.0]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[pacopascal.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:22612, ipnet:68.65.122.0/24, country:US]; MID_RHS_NOT_FQDN(0.50)[]; IP_SCORE(-0.70)[ipnet: 68.65.122.0/24(-4.01), asn: 22612(0.58), country: US(-0.06)] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2019 05:10:45 -0000 Hello, I'm new at attempting to contribute to the FreeBSD project. As an introduction to working on FreeBSD, I started searching the bug database and settled into bug #235589. If I've made an error in my approach to the community, just let me know. I'm not sure what the wisest method is to fix this, given I'm not familiar with the code-base. Also, it's not clear what the correct behavior of LINENO should be. FreeBSD's shell treats LINENO differently than bash. For example, cmd='echo $LINENO $((LINENO)) $(($LINENO))' f() { eval ${cmd} echo $LINENO $((LINENO)) $(($LINENO)) } eval ${cmd} echo $LINENO $((LINENO)) $(($LINENO)) f has the following output in bash, 8 8 8 9 9 9 4 4 4 5 5 5 while FreeBSD's shell outputs, 1 0 1 9 0 9 1 0 1 3 0 3 . The reason for the bug (and difference in behavior) is because LINENO isn't treated as other variables are; it's value can't be looked up using lookupvar() from var.c which is what arith() eventually does when trying to find the value of a variable that isn't preceded by a "$". So, the first thing I need to ask before I go any further is, what's the expected behavior in the above conditions? // Paco