From b90cb5a280ebb8ac03306a5b19aea6b997c71ee7 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 7 Jun 2017 15:30:55 -0400 Subject: [PATCH] commit bash-20170601 snapshot --- CWRU/CWRU.chlog | 20 ++++++++++++++++++++ config.h.in | 1 + doc/bash.1 | 2 +- lib/glob/sm_loop.c | 18 ++++++++++++++---- tests/RUN-ONE-TEST | 2 +- variables.c | 12 +++++++++++- variables.h | 2 ++ 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index bc1155bb..c9f8acad 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -14000,3 +14000,23 @@ builtins/read.def - read_builtin: if -n or -N option is supplied with a 0 argument, don't attempt to read any characters; bail out right away. Reported by Eduardo Bustamante , relaying from IRC + + 6/3 + --- +config.h.in + - HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC: add define, used by stat-time.h + to construct a timespec from struct stat. Report and fix from + Siteshwar Vashisht + +variables.h + - att_regenerate: new internal variable attribute: if set, regenerate + dynamic variable's value when it's exported and we are creating the + export environment + +variables.c + - init_dynamic_variables: LINENO, EPOCHSECONDS, EPOCHREALTIME: set + internal regenerate attribute for these dynamic variables + - make_env_array_from_var_list: if a dynamic variable has the + regenerate attribute set, call the dynamic value function to generate + an updated value before placing it in the environment. From a report + about exporting LINENO from by Robert Elz diff --git a/config.h.in b/config.h.in index b5c35c38..1e4b71d1 100644 --- a/config.h.in +++ b/config.h.in @@ -452,6 +452,7 @@ #undef SYS_TIME_H_DEFINES_STRUCT_TIMESPEC #undef PTHREAD_H_DEFINES_STRUCT_TIMESPEC +#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC #undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC #undef HAVE_STRUCT_STAT_ST_ATIMENSEC diff --git a/doc/bash.1 b/doc/bash.1 index 4f42e6d2..25c5ff42 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -6837,7 +6837,7 @@ If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value, or a numeric value less than zero, the history file is not truncated. When the history file is read, lines beginning with the history comment character followed immediately -by a digit are interpreted as timestamps for the preceding history line. +by a digit are interpreted as timestamps for the following history line. These timestamps are optionally displayed depending on the value of the .SM .B HISTTIMEFORMAT diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index 78499c4b..a8129286 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -384,7 +384,7 @@ BRACKMATCH (p, test, flags) { register CHAR cstart, cend, c; register int not; /* Nonzero if the sense of the character class is inverted. */ - int brcnt, forcecoll; + int brcnt, brchr, forcecoll; INT pc; CHAR *savep; U_CHAR orig_test; @@ -460,7 +460,7 @@ BRACKMATCH (p, test, flags) if (pc == -1) pc = 0; else - p = close + 2; + p = close + 2; /* move past the closing `]' */ free (ccname); } @@ -577,16 +577,26 @@ matched: /* Skip the rest of the [...] that already matched. */ c = *--p; brcnt = 1; + brchr = 0; while (brcnt > 0) { + int oc; + /* A `[' without a matching `]' is just another character to match. */ if (c == L('\0')) return ((test == L('[')) ? savep : (CHAR *)0); + oc = c; c = *p++; if (c == L('[') && (*p == L('=') || *p == L(':') || *p == L('.'))) - brcnt++; - else if (c == L(']')) + { + brcnt++; + brchr = *p; + } + /* we only want to check brchr if we set it above */ + else if (c == L(']') && brcnt > 1 && brchr != 0 && oc == brchr) + brcnt--; + else if (c == L(']') && brcnt == 1) brcnt--; else if (!(flags & FNM_NOESCAPE) && c == L('\\')) { diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 58c375b7..554f3d6e 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/chet/bash/bash-current +BUILD_DIR=/usr/local/build/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR diff --git a/variables.c b/variables.c index 02ab5f56..a08313d7 100644 --- a/variables.c +++ b/variables.c @@ -1825,13 +1825,15 @@ initialize_dynamic_variables () INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random); VSETATTR (v, att_integer); INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno); - VSETATTR (v, att_integer); + VSETATTR (v, att_integer|att_regenerate); INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign); VSETATTR (v, att_integer); INIT_DYNAMIC_VAR ("EPOCHSECONDS", (char *)NULL, get_epochseconds, null_assign); + VSETATTR (v, att_regenerate); INIT_DYNAMIC_VAR ("EPOCHREALTIME", (char *)NULL, get_epochrealtime, null_assign); + VSETATTR (v, att_regenerate); #if defined (HISTORY) INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL); @@ -4449,6 +4451,14 @@ make_env_array_from_var_list (vars) /* We don't use the exportstr stuff on Cygwin at all. */ INVALIDATE_EXPORTSTR (var); #endif + + /* If the value is generated dynamically, generate it here. */ + if (regen_p (var) && var->dynamic_value) + { + var = (*(var->dynamic_value)) (var); + INVALIDATE_EXPORTSTR (var); + } + if (var->exportstr) value = var->exportstr; else if (function_p (var)) diff --git a/variables.h b/variables.h index 46883c92..5569383b 100644 --- a/variables.h +++ b/variables.h @@ -125,6 +125,7 @@ typedef struct _vlist { #define att_imported 0x0008000 /* came from environment */ #define att_special 0x0010000 /* requires special handling */ #define att_nofree 0x0020000 /* do not free value on unset */ +#define att_regenerate 0x0040000 /* regenerate when exported */ #define attmask_int 0x00ff000 @@ -153,6 +154,7 @@ typedef struct _vlist { #define imported_p(var) ((((var)->attributes) & (att_imported))) #define specialvar_p(var) ((((var)->attributes) & (att_special))) #define nofree_p(var) ((((var)->attributes) & (att_nofree))) +#define regen_p(var) ((((var)->attributes) & (att_regenerate))) #define tempvar_p(var) ((((var)->attributes) & (att_tempvar)))