diff options
Diffstat (limited to '')
-rw-r--r-- | src/var.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/var.c b/src/var.c index aec1076..ecc8c90 100644 --- a/src/var.c +++ b/src/var.c @@ -33,6 +33,7 @@ */ #include <unistd.h> +#include <stdio.h> #include <stdlib.h> #ifdef HAVE_PATHS_H #include <paths.h> @@ -80,6 +81,9 @@ const char defifsvar[] = "IFS= \t\n"; const char defifs[] = " \t\n"; #endif +int lineno; +char linenovar[sizeof("LINENO=")+sizeof(int)*CHAR_BIT/3+1] = "LINENO="; + /* Some macros in var.h depend on the order, add new variables to the end. */ struct var varinit[] = { #if ATTY @@ -97,11 +101,11 @@ struct var varinit[] = { { 0, VSTRFIXED|VTEXTFIXED, "PS2=> ", 0 }, { 0, VSTRFIXED|VTEXTFIXED, "PS4=+ ", 0 }, { 0, VSTRFIXED|VTEXTFIXED, "OPTIND=1", getoptsreset }, + { 0, VSTRFIXED|VTEXTFIXED, linenovar, 0 }, #ifndef SMALL { 0, VSTRFIXED|VTEXTFIXED|VUNSET, "TERM\0", 0 }, { 0, VSTRFIXED|VTEXTFIXED|VUNSET, "HISTSIZE\0", sethistsize }, #endif - { 0, VSTRFIXED|VTEXTFIXED, "LINENO=1", 0 }, }; STATIC struct var *vartab[VTABSIZE]; @@ -331,6 +335,9 @@ lookupvar(const char *name) struct var *v; if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) { + if (v == &vlineno && v->text == linenovar) { + fmtstr(linenovar+7, sizeof(linenovar)-7, "%d", lineno); + } return strchrnul(v->text, '=') + 1; } return NULL; |