Module Name: src Committed By: kre Date: Thu Jun 8 02:23:52 UTC 2017
Modified Files: src/bin/sh: Makefile eval.c sh.1 Log Message: Improve the (new) LINENO section, markup changes (with thanks to wiz@ for assistace) and some better wording in a few placed. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/bin/sh/Makefile cvs rdiff -u -r1.143 -r1.144 src/bin/sh/eval.c cvs rdiff -u -r1.150 -r1.151 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/Makefile diff -u src/bin/sh/Makefile:1.110 src/bin/sh/Makefile:1.111 --- src/bin/sh/Makefile:1.110 Mon May 29 14:03:23 2017 +++ src/bin/sh/Makefile Thu Jun 8 02:23:51 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.110 2017/05/29 14:03:23 kre Exp $ +# $NetBSD: Makefile,v 1.111 2017/06/08 02:23:51 kre Exp $ # @(#)Makefile 8.4 (Berkeley) 5/5/95 .include <bsd.own.mk> @@ -26,9 +26,11 @@ SCRIPT_ENV= \ CPPFLAGS+=-DSHELL -I. -I${.CURDIR} #XXX: For testing only. #CPPFLAGS+=-DDEBUG=3 -#COPTS+=-g +CPPFLAGS+=-DDEBUG=1 +COPTS+=-g #CFLAGS+=-funsigned-char #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char +CFLAGS+=-Wall # Reproducible build parameters ... export into sh for NETBSD_SHELL setting .if ${MKREPRO_TIMESTAMP:Uno} != "no" Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.143 src/bin/sh/eval.c:1.144 --- src/bin/sh/eval.c:1.143 Wed Jun 7 05:08:32 2017 +++ src/bin/sh/eval.c Thu Jun 8 02:23:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.143 2017/06/07 05:08:32 kre Exp $ */ +/* $NetBSD: eval.c,v 1.144 2017/06/08 02:23:51 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.143 2017/06/07 05:08:32 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.144 2017/06/08 02:23:51 kre Exp $"); #endif #endif /* not lint */ @@ -776,7 +776,8 @@ evalcommand(union node *cmd, int flgs, s vforked = 0; /* First expand the arguments. */ - TRACE(("evalcommand(%p, %d) called\n", cmd, flags)); + CTRACE(DBG_EVAL, ("evalcommand(%p, %d) called (%d)\n", cmd, flags, + (cmd ? cmd->ncmd.lineno : -1))); setstackmark(&smark); back_exitstatus = 0; Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.150 src/bin/sh/sh.1:1.151 --- src/bin/sh/sh.1:1.150 Wed Jun 7 13:49:48 2017 +++ src/bin/sh/sh.1 Thu Jun 8 02:23:51 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.150 2017/06/07 13:49:48 wiz Exp $ +.\" $NetBSD: sh.1,v 1.151 2017/06/08 02:23:51 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -2868,12 +2868,15 @@ and can be unset. All of those act as they would with any other variable. However, .Ev LINENO -should normally not ever be set, in this -shell doing so reverses the effect of an earlier unset, +should normally not ever be set or unset. +In this shell setting +.Ev LINENO +reverses the effect of an earlier +.Ic unset , but does not otherwise affect the value obtained. If unset, .Ev LINENO -should not be set again. +should not normally be set again, doing so is not portable. If .Ev LINENO is set or unset, different shells act differently. @@ -2896,9 +2899,11 @@ Line numbers are counted from 1, which i reads from any particular file. For this shell, standard input, including in an interactive shell, the user's terminal, is just another file and lines are counted -there as well, however note that not all shells count interactive -lines this way, it is wise to rely upon LINENO only having a useful -value in a script, or a function. +there as well. +However note that not all shells count interactive +lines this way, it is not wise to rely upon +.Ev LINENO +having a useful value, except in a script, or a function. .Pp The role of .Ev LINENO @@ -2917,7 +2922,9 @@ If the .Fl L flag (the .Ic lineno_fn_relative -option) is set, when the function is defined, then the function +option, see +.Sx Argument List Processing ) +is set, when the function is defined, then the function defaults to counting lines with one being the first line of the function. When the @@ -2936,7 +2943,7 @@ behavior it prefers. If .Ev LINENO is made local and inherited, and not given a value, as in -.Dl local -I LINENO +.Dl local Fl I Ev LINENO then from that point in the function, .Ev LINENO will give the line number as if lines are counted in sequence @@ -2944,14 +2951,14 @@ with the lines that surround the functio If .Ev LINENO is made local, and in that same command, given a value, as -.Dl local Oo Fl I Ns Cm \&| Ns Fl N Ns Oc LINENO=value +.Dl local Oo Fl I Ns | Ns Fl N Oc Ev LINENO Ns = Ns Ar value then .Ev LINENO will give the line number as if lines are counted from one from the beginning of the function. The value nominally assigned in this case is irrelevant, and ignored. For completeness, if lineno is made local and unset, as in -.Dl local -N LINENO +.Dl local Fl N Ev LINENO then .Ev LINENO is simply unset inside the function, and gives no value at all.