fix for %P in TIMEFORMAT; make updating variables that aren't subject to allexport smoother; fix spurious compiler warning about realloc; efficiency improvement for command timing; fix issue with read builtin and failure to set terminal attributes

This commit is contained in:
Chet Ramey
2025-10-06 15:29:41 -04:00
parent 4f536430e4
commit f2f545ad7b
11 changed files with 118 additions and 80 deletions
+2 -4
View File
@@ -622,8 +622,7 @@ read_builtin (WORD_LIST *list)
termsave.attrs = ttattrs;
ttset = ttattrs;
i = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset);
if (i < 0)
if ((silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset)) < 0)
sh_ttyerror (1);
tty_modified = 1;
add_unwind_protect (uw_ttyrestore, &termsave);
@@ -639,8 +638,7 @@ read_builtin (WORD_LIST *list)
termsave.attrs = ttattrs;
ttset = ttattrs;
i = ttfd_noecho (fd, &ttset); /* ttnoecho (); */
if (i < 0)
if (ttfd_noecho (fd, &ttset) < 0)
sh_ttyerror (1);
tty_modified = 1;
+5 -14
View File
@@ -532,7 +532,7 @@ set_shellopts (void)
{
char *value;
char tflag[N_O_OPTIONS];
int i, *ip, exported;
int i, *ip;
size_t vsize, vptr;
SHELL_VAR *v;
@@ -571,21 +571,12 @@ set_shellopts (void)
vptr--; /* cut off trailing colon */
value[vptr] = '\0';
v = find_variable ("SHELLOPTS");
/* ASS_FORCE so we don't have to temporarily turn off readonly; ASS_NOEXPORT
so we don't have to work around allexport. */
v = bind_variable ("SHELLOPTS", value, ASS_FORCE|ASS_NOEXPORT);
/* Note whether or not the variable was exported so we can adjust after the
assignment. */
exported = v ? exported_p (v) : 0;
/* ASS_FORCE so we don't have to temporarily turn off readonly */
v = bind_variable ("SHELLOPTS", value, ASS_FORCE);
/* Turn the read-only attribute back on, and turn off the export attribute
if it was set implicitly by mark_modified_vars and SHELLOPTS was not
exported before we bound the new value. */
/* Turn the read-only attribute back on. */
VSETATTR (v, att_readonly);
if (mark_modified_vars && exported == 0 && exported_p (v))
VUNSETATTR (v, att_exported);
free (value);
}
+4 -11
View File
@@ -823,7 +823,7 @@ set_bashopts (void)
{
char *value;
char tflag[N_SHOPT_OPTIONS];
int i, exported;
int i;
size_t vsize, vptr;
SHELL_VAR *v;
@@ -853,21 +853,14 @@ set_bashopts (void)
vptr--; /* cut off trailing colon */
value[vptr] = '\0';
v = find_variable ("BASHOPTS");
/* Note whether or not the variable was exported so we can adjust after the
assignment. */
exported = v ? exported_p (v) : 0;
/* ASS_FORCE so we don't have to temporarily turn off readonly */
v = bind_variable ("BASHOPTS", value, ASS_FORCE);
/* ASS_FORCE so we don't have to temporarily turn off readonly; ASS_NOEXPORT
so we don't have to work around allexport. */
v = bind_variable ("BASHOPTS", value, ASS_FORCE|ASS_NOEXPORT);
/* Turn the read-only attribute back on, and turn off the export attribute
if it was set implicitly by mark_modified_vars and SHELLOPTS was not
exported before we bound the new value. */
VSETATTR (v, att_readonly);
if (mark_modified_vars && exported == 0 && exported_p (v))
VUNSETATTR (v, att_exported);
free (value);
}