View | Details | Raw Unified | Return to bug 235589 | Differences between
and this patch

Collapse All | Expand All

(-)eval.c (-1 / +7 lines)
Lines 78-85 Link Here
78
static int loopnest;		/* current loop nesting level */
78
static int loopnest;		/* current loop nesting level */
79
int funcnest;			/* depth of function calls */
79
int funcnest;			/* depth of function calls */
80
static int builtin_flags;	/* evalcommand flags for builtins */
80
static int builtin_flags;	/* evalcommand flags for builtins */
81
static int elinno;
81
82
82
83
char *commandname;
83
char *commandname;
84
struct arglist *cmdenviron;
84
struct arglist *cmdenviron;
85
int exitstatus;			/* exit status of last command */
85
int exitstatus;			/* exit status of last command */
Lines 809-814 Link Here
809
	return (0);
809
	return (0);
810
}
810
}
811
811
812
int getelinno()
813
{
814
	return elinno;
815
}
816
812
/*
817
/*
813
 * Execute a simple command.
818
 * Execute a simple command.
814
 * Note: This may or may not return if (flags & EV_EXIT).
819
 * Note: This may or may not return if (flags & EV_EXIT).
Lines 853-858 Link Here
853
	/* Add one slot at the beginning for tryexec(). */
858
	/* Add one slot at the beginning for tryexec(). */
854
	appendarglist(&arglist, nullstr);
859
	appendarglist(&arglist, nullstr);
855
	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
860
	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
861
		elinno = argp->narg.linno;
856
		if (varflag && isassignment(argp->narg.text)) {
862
		if (varflag && isassignment(argp->narg.text)) {
857
			expandarg(argp, varflag == 1 ? &varlist : &arglist,
863
			expandarg(argp, varflag == 1 ? &varlist : &arglist,
858
			    EXP_VARTILDE);
864
			    EXP_VARTILDE);
(-)eval.h (+1 lines)
Lines 57-62 Link Here
57
union node;	/* BLETCH for ansi C */
57
union node;	/* BLETCH for ansi C */
58
void evaltree(union node *, int);
58
void evaltree(union node *, int);
59
void evalbackcmd(union node *, struct backcmd *);
59
void evalbackcmd(union node *, struct backcmd *);
60
int getelinno();
60
61
61
/* in_function returns nonzero if we are currently evaluating a function */
62
/* in_function returns nonzero if we are currently evaluating a function */
62
#define in_function()	funcnest
63
#define in_function()	funcnest
(-)nodetypes (+1 lines)
Lines 108-113 Link Here
108
108
109
NARG narg			# represents a word
109
NARG narg			# represents a word
110
	type	  int
110
	type	  int
111
	linno     int
111
	next	  nodeptr		# next word in list
112
	next	  nodeptr		# next word in list
112
	text	  string		# the text of the word
113
	text	  string		# the text of the word
113
	backquote nodelist		# list of commands in back quotes
114
	backquote nodelist		# list of commands in back quotes
(-)parser.c (-1 / +5 lines)
Lines 704-709 Link Here
704
704
705
	n = (union node *)stalloc(sizeof (struct narg));
705
	n = (union node *)stalloc(sizeof (struct narg));
706
	n->type = NARG;
706
	n->type = NARG;
707
	if (funclinno)
708
		n->narg.linno = plinno - funclinno;
709
	else
710
		n->narg.linno = plinno;
707
	n->narg.next = NULL;
711
	n->narg.next = NULL;
708
	n->narg.text = wordtext;
712
	n->narg.text = wordtext;
709
	n->narg.backquote = backquotelist;
713
	n->narg.backquote = backquotelist;
Lines 1664-1670 Link Here
1664
				CHECKSTRSPACE(11, out);
1668
				CHECKSTRSPACE(11, out);
1665
				linno = plinno;
1669
				linno = plinno;
1666
				if (funclinno != 0)
1670
				if (funclinno != 0)
1667
					linno -= funclinno - 1;
1671
					linno -= funclinno;
1668
				length = snprintf(out, 11, "%d", linno);
1672
				length = snprintf(out, 11, "%d", linno);
1669
				if (length > 10)
1673
				if (length > 10)
1670
					length = 10;
1674
					length = 10;
(-)var.c (+7 lines)
Lines 429-434 Link Here
429
{
429
{
430
	struct var *v;
430
	struct var *v;
431
431
432
	if (strcmp("LINENO", name) == 0) {
433
		static char buf[11];
434
		bzero(buf, 11);
435
		snprintf(buf, 11, "%d", getelinno());
436
		return buf;
437
	}
438
432
	v = find_var(name, NULL, NULL);
439
	v = find_var(name, NULL, NULL);
433
	if (v == NULL || v->flags & VUNSET)
440
	if (v == NULL || v->flags & VUNSET)
434
		return NULL;
441
		return NULL;

Return to bug 235589