Date: Mon, 15 Jul 2019 02:25:40 -0500 From: "Clay Daniels Jr." <clay.daniels.jr@gmail.com> To: Paco Pascal <me@pacopascal.com>, freebsd-hackers@freebsd.org Subject: Re: What's the expected behavior of LINENO from /bin/sh? Message-ID: <CAGLDxTVfJiAPkMqf_35J7pV-54OSGhQNUec34NU2wWDRniA%2B%2BA@mail.gmail.com> In-Reply-To: <20190715051033.GA2591@gauss> References: <20190715051033.GA2591@gauss>
next in thread | previous in thread | raw e-mail | index | archive | help
Paco, I got curious about $LINENO & noticed that it is only available in sh, but not csh nor tcsh: clay@bsd13:/usr/home/clay $ echo $SHELL /bin/sh clay@bsd13:/usr/home/clay $ echo $LINENO 2 clay@bsd13:/usr/home/clay $ cat /etc/shells # $FreeBSD: head/etc/shells 348185 2019-05-23 18:37:05Z bapt $ # # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/sh /bin/csh /bin/tcsh clay@bsd13:/usr/home/clay $ /bin/csh clay@bsd13:~ % echo $LINENO LINENO: Undefined variable. clay@bsd13:~ % /bin/tcsh clay@bsd13:~ % echo $LINENO LINENO: Undefined variable. clay@bsd13:~ % /bin/sh clay@bsd13:~ $ echo $LINENO $((LINENO)) $(($LINENO)) 1 0 1 clay@bsd13:~ $ On Mon, Jul 15, 2019 at 12:11 AM Paco Pascal <me@pacopascal.com> wrote: > 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 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGLDxTVfJiAPkMqf_35J7pV-54OSGhQNUec34NU2wWDRniA%2B%2BA>