NetBSD/bin/sh
kre fd38bbe2e4 An initial attempt at implementing LINENO to meet the specs.
Aside from one problem (not too hard to fix if it was ever needed) this version
does about as well as most other shell implementations when expanding
$((LINENO)) and better for ${LINENO} as it retains the "LINENO hack" for the
latter, and that is very accurate.

Unfortunately that means that ${LINENO} and $((LINENO)) do not always produce
the same value when used on the same line (a defect that other shells do not
share - aside from the FreeBSD sh as it is today, where only the LINENO hack
exists and so (like for us before this commit) $((LINENO)) is always either
0, or at least whatever value was last set, perhaps by
	LINENO=${LINENO}
which does actually work ... for that one line...)

This could be corrected by simply removing the LINENO hack (look for the string
LINENO in parser.c) in which case ${LINENO} and $((LINENO)) would give the
same (not perfectly accurate) values, as do most other shells.

POSIX requires that LINENO be set before each command, and this implementation
does that fairly literally - except that we only bother before the commands
which actually expand words (for, case and simple commands).   Unfortunately
this forgot that expansions also occur in redirects, and the other compound
commands can also have redirects, so if a redirect on one of the other compound
commands wants to use the value of $((LINENO)) as a part of a generated file
name, then it will get an incorrect value.  This is the "one problem" above.
(Because the LINENO hack is still enabled, using ${LINENO} works.)

This could be fixed, but as this version of the LINENO implementation is just
for reference purposes (it will be superseded within minutes by a better one)
I won't bother.  However should anyone else decide that this is a better choice
(it is probably a smaller implementation, in terms of code & data space then
the replacement, but also I would expect, slower, and definitely less accurate)
this defect is something to bear in mind, and fix.

This version retains the *BSD historical practice that line numbers in functions
(all functions) count from 1 from the start of the function, and elsewhere,
start from 1 from where the shell started reading the input file/stream in
question.  In an "eval" expression the line number starts at the line of the
"eval" (and then increases if the input is a multi-line string).

Note: this version is not documented (beyond as much as LINENO was before)
hence this slightly longer than usual commit message.
2017-06-07 04:44:17 +00:00
..
USD.doc Reorg docs, part 2: 2014-07-05 19:23:00 +00:00
bltin Avoid warning by using gcc'ism 2016-03-16 22:36:21 +00:00
funcs delete clauses 3,4 2016-02-29 23:50:59 +00:00
Makefile More DEBUG mode changes. As usual, read the source if you care. 2017-05-29 14:03:23 +00:00
TOUR Fix grammar in couple of sentences. 2016-10-25 13:01:59 +00:00
alias.c Adjust to the new alias text libedit API. 2014-06-18 18:17:30 +00:00
alias.h Adjust to the new alias text libedit API. 2014-06-18 18:17:30 +00:00
arith_token.c Add DEBUG tracing to arithmetic $(( )) parsing & evaluation. 2017-05-29 22:54:07 +00:00
arith_tokens.h Finish support for all required $(( )) (shell arithmetic) operators, 2017-03-20 11:26:07 +00:00
arithmetic.c Add DEBUG tracing to arithmetic $(( )) parsing & evaluation. 2017-05-29 22:54:07 +00:00
arithmetic.h Finish support for all required $(( )) (shell arithmetic) operators, 2017-03-20 11:26:07 +00:00
builtins.def DEBUG mode shell update (changes nothing for shells which are not 2017-05-15 20:00:36 +00:00
cd.c Make cd (really) do cd -P, and not just claim that is what it is doing 2017-06-04 20:27:14 +00:00
cd.h
error.c PR bin/47065 PR bin/39466 2016-06-01 02:50:02 +00:00
error.h
eval.c An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
eval.h PR bin/48875 - avoid holding (replaced) file descriptors open when running a 2016-05-09 21:03:10 +00:00
exec.c Make cd (really) do cd -P, and not just claim that is what it is doing 2017-06-04 20:27:14 +00:00
exec.h Make cd (really) do cd -P, and not just claim that is what it is doing 2017-06-04 20:27:14 +00:00
expand.c Another arithmetic expansion recordregion() fix, this time 2017-06-05 02:15:55 +00:00
expand.h Fixes to shell expand (that is, $ stuff) from FreeBSD (implemented 2017-06-03 10:31:16 +00:00
histedit.c Sprinkle volatile for gcc 5! 2016-03-16 22:36:40 +00:00
init.h
input.c An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
input.h An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
jobs.c DEBUG mode only change - correctly track internal shell sub-shell nesting 2017-05-18 13:34:17 +00:00
jobs.h
machdep.h
mail.c If we are going to keep the MAILPATH % hack, then at least do something 2017-06-04 20:28:13 +00:00
mail.h
main.c More DEBUG mode changes. As usual, read the source if you care. 2017-05-29 14:03:23 +00:00
main.h
memalloc.c
memalloc.h Fixes to shell expand (that is, $ stuff) from FreeBSD (implemented 2017-06-03 10:31:16 +00:00
miscbltin.c Fix inconsistent whitespace 2017-05-13 15:03:34 +00:00
miscbltin.h
mkbuiltins
mkinit.sh General KNF and source code cleanups, avoid scattering the 2016-03-27 14:34:46 +00:00
mknodenames.sh General KNF and source code cleanups, avoid scattering the 2016-03-27 14:34:46 +00:00
mknodes.sh
mkoptions.sh Redo mkoptions.sh .. much better this way, now fully automated 2017-05-28 14:14:22 +00:00
mktokens Implement the ';&' (used instead of ';;') case statement list terminator 2017-05-04 04:37:51 +00:00
myhistedit.h
mystring.c
mystring.h
nodes.c.pat
nodetypes An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
option.list Redo mkoptions.sh .. much better this way, now fully automated 2017-05-28 14:14:22 +00:00
options.c More DEBUG mode changes. As usual, read the source if you care. 2017-05-29 14:03:23 +00:00
options.h Arrange for set -o and $- output to be sorted, rather than more 2017-05-28 00:38:01 +00:00
output.c Added comma and plus to the "don't need quoting" set. This affects 2017-05-18 13:31:10 +00:00
output.h
parser.c An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
parser.h After discussions with Jilles Tjoelker (FreeBSD shell) and 2016-03-31 23:11:05 +00:00
redir.c Now that the shell is protecting its internal fds properly, moving 2017-05-29 22:21:00 +00:00
redir.h Keep track of which file descriptors the shell is using for its 2017-04-29 15:14:28 +00:00
sh.1 Fix a typo (or rather a remnant of an earlier intent). 2017-06-06 22:38:52 +00:00
shell.h More DEBUG mode changes. As usual, read the source if you care. 2017-05-29 14:03:23 +00:00
show.c More DEBUG mode changes. As usual, read the source if you care. 2017-05-29 14:03:23 +00:00
show.h The beginnings of the great shell DEBUG (tracing) upgrade of 2017... 2017-05-13 03:26:03 +00:00
syntax.c
syntax.h DEBUG mode shell update (changes nothing for shells which are not 2017-05-15 20:00:36 +00:00
trap.c Enhance the trap command to make it possible to do what POSIX wants 2017-05-07 15:01:18 +00:00
trap.h report the signal that wait was interrupted by, which is not always SIGINT 2015-08-22 12:12:47 +00:00
var.c An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
var.h An initial attempt at implementing LINENO to meet the specs. 2017-06-07 04:44:17 +00:00
version.h replace with standard copyright :-) 2016-03-31 16:28:23 +00:00