FreeBSD Bugzilla – Attachment 206211 Details for
Bug 235589
sh(1): LINENO is unset in shell arithmetic
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed fix patch
lineno-patch.diff (text/plain), 2.72 KB, created by
Paco Pascal
on 2019-08-02 02:42:15 UTC
(
hide
)
Description:
Proposed fix patch
Filename:
MIME Type:
Creator:
Paco Pascal
Created:
2019-08-02 02:42:15 UTC
Size:
2.72 KB
patch
obsolete
>Index: eval.c >=================================================================== >--- eval.c (revision 350485) >+++ eval.c (working copy) >@@ -78,8 +78,8 @@ > static int loopnest; /* current loop nesting level */ > int funcnest; /* depth of function calls */ > static int builtin_flags; /* evalcommand flags for builtins */ >+static int elinno; > >- > char *commandname; > struct arglist *cmdenviron; > int exitstatus; /* exit status of last command */ >@@ -809,6 +809,11 @@ > return (0); > } > >+int getelinno() >+{ >+ return elinno; >+} >+ > /* > * Execute a simple command. > * Note: This may or may not return if (flags & EV_EXIT). >@@ -853,6 +858,7 @@ > /* Add one slot at the beginning for tryexec(). */ > appendarglist(&arglist, nullstr); > for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { >+ elinno = argp->narg.linno; > if (varflag && isassignment(argp->narg.text)) { > expandarg(argp, varflag == 1 ? &varlist : &arglist, > EXP_VARTILDE); >Index: eval.h >=================================================================== >--- eval.h (revision 350485) >+++ eval.h (working copy) >@@ -57,6 +57,7 @@ > union node; /* BLETCH for ansi C */ > void evaltree(union node *, int); > void evalbackcmd(union node *, struct backcmd *); >+int getelinno(); > > /* in_function returns nonzero if we are currently evaluating a function */ > #define in_function() funcnest >Index: nodetypes >=================================================================== >--- nodetypes (revision 350485) >+++ nodetypes (working copy) >@@ -108,6 +108,7 @@ > > NARG narg # represents a word > type int >+ linno int > next nodeptr # next word in list > text string # the text of the word > backquote nodelist # list of commands in back quotes >Index: parser.c >=================================================================== >--- parser.c (revision 350485) >+++ parser.c (working copy) >@@ -704,6 +704,10 @@ > > n = (union node *)stalloc(sizeof (struct narg)); > n->type = NARG; >+ if (funclinno) >+ n->narg.linno = plinno - funclinno; >+ else >+ n->narg.linno = plinno; > n->narg.next = NULL; > n->narg.text = wordtext; > n->narg.backquote = backquotelist; >@@ -1664,7 +1668,7 @@ > CHECKSTRSPACE(11, out); > linno = plinno; > if (funclinno != 0) >- linno -= funclinno - 1; >+ linno -= funclinno; > length = snprintf(out, 11, "%d", linno); > if (length > 10) > length = 10; >Index: var.c >=================================================================== >--- var.c (revision 350485) >+++ var.c (working copy) >@@ -429,6 +429,13 @@ > { > struct var *v; > >+ if (strcmp("LINENO", name) == 0) { >+ static char buf[11]; >+ bzero(buf, 11); >+ snprintf(buf, 11, "%d", getelinno()); >+ return buf; >+ } >+ > v = find_var(name, NULL, NULL); > if (v == NULL || v->flags & VUNSET) > return NULL;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 235589
:
206211
|
212048
|
212062