Date: Mon, 15 Jul 2019 01:10:33 -0400 From: Paco Pascal <me@pacopascal.com> To: freebsd-hackers@freebsd.org Subject: What's the expected behavior of LINENO from /bin/sh? Message-ID: <20190715051033.GA2591@gauss>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190715051033.GA2591>