commit bash-20200812 snapshot

This commit is contained in:
Chet Ramey
2020-08-14 14:34:20 -04:00
parent 7a257517b7
commit 6dc203b865
9 changed files with 65 additions and 16 deletions
+16
View File
@@ -8873,3 +8873,19 @@ builtins/fc.def
specifications, clamp them at the beginning or end of the history
list, as appropriate, per POSIX. Report and fix from Martijn Dekker
<martijn@inlv.org>
8/12
----
builtins/fc.def
- fc_gethnum: return HIST_NOTFOUND (new error) if the string is not a
number and doesn't correspond to any command in the history list
- fc_builtin: print a "no command found" error message if fc_gethnum
returns HIST_NOTFOUND
8/14
----
flags.c
- no_invisible_vars: removed undocumented `-I' flag
{flags,variables}.c,flags.h,builtins/{declare,setattr.def}
- no_invisible_vars: remove all references
+3 -3
View File
@@ -727,20 +727,20 @@ restart_new_var_name:
if (flags_on & att_assoc)
{
var = make_new_assoc_variable (name);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
else if ((flags_on & att_array) || making_array_special)
{
var = make_new_array_variable (name);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
else
#endif
{
var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE);
if (var && offset == 0 && no_invisible_vars == 0)
if (var && offset == 0)
VSETATTR (var, att_invisible);
}
if (var == 0)
+22 -1
View File
@@ -88,6 +88,7 @@ extern int errno;
#define HIST_INVALID INT_MIN
#define HIST_ERANGE INT_MIN+1
#define HIST_NOTFOUND INT_MIN+2
extern int unlink PARAMS((const char *));
@@ -358,6 +359,16 @@ fc_builtin (list)
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_ERANGE || histend == HIST_ERANGE)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_NOTFOUND || histend == HIST_NOTFOUND)
{
builtin_error (_("no command found"));
return (EXECUTION_FAILURE);
}
/* We don't throw an error for line specifications out of range, per POSIX */
if (histbeg < 0)
@@ -392,6 +403,16 @@ fc_builtin (list)
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_ERANGE || histend == HIST_ERANGE)
{
sh_erange ((char *)NULL, _("history specification"));
return (EXECUTION_FAILURE);
}
else if (histbeg == HIST_NOTFOUND || histend == HIST_NOTFOUND)
{
builtin_error (_("no command found"));
return (EXECUTION_FAILURE);
}
/* We don't throw an error for line specifications out of range, per POSIX */
if (histbeg < 0)
@@ -602,7 +623,7 @@ fc_gethnum (command, hlist, mode)
if (STREQN (command, histline (j), clen))
return (j);
}
return (-1);
return (HIST_NOTFOUND);
}
/* Locate the most recent history line which begins with
+1 -1
View File
@@ -645,7 +645,7 @@ set_var_attribute (name, attribute, undo)
if (var == 0)
{
var = bind_variable (name, (char *)NULL, 0);
if (var && no_invisible_vars == 0)
if (var)
VSETATTR (var, att_invisible);
}
else if (var->context != 0)
+1 -5
View File
@@ -112,9 +112,6 @@ int no_symbolic_links = 0;
int lexical_scoping = 0;
#endif
/* Non-zero means no such thing as invisible variables. */
int no_invisible_vars = 0;
/* Non-zero means look up and remember command names in a hash table, */
int hashing_enabled = 1;
@@ -201,7 +198,6 @@ const struct flags_alist shell_flags[] = {
#if defined (BANG_HISTORY)
{ 'H', &histexp_flag },
#endif /* BANG_HISTORY */
{ 'I', &no_invisible_vars },
{ 'P', &no_symbolic_links },
{ 'T', &function_trace_mode },
{0, (int *)NULL}
@@ -349,7 +345,7 @@ reset_shell_flags ()
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
noclobber = unbound_vars_is_error = 0;
echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
no_symbolic_links = no_invisible_vars = 0;
no_symbolic_links = 0;
privileged_mode = pipefail_opt = 0;
error_trace_mode = function_trace_mode = 0;
+1 -1
View File
@@ -45,7 +45,7 @@ extern int
disallow_filename_globbing,
place_keywords_in_env, read_but_dont_execute,
just_one_command, unbound_vars_is_error, echo_input_at_read, verbose_flag,
echo_command_at_execute, no_invisible_vars, noclobber,
echo_command_at_execute, noclobber,
hashing_enabled, forced_interactive, privileged_mode, jobs_m_flag,
asynchronous_notification, interactive_comments, no_symbolic_links,
function_trace_mode, error_trace_mode, pipefail_opt;
+2 -2
View File
@@ -97,11 +97,11 @@ line 2 for history
6 HISTFILE=$TMPDIR/newhistory
7 echo displaying \$HISTFILE after history -a
8 cat $HISTFILE
1 for i in one two three; do echo $i; done
./history.tests: line 90: fc: no command found
15 echo line 2 for history
16 unset HISTSIZE
17 unset HISTFILE
18 # no longer an out-of-range error
18 # now an out-of-range error because of the one=two not found in history
aa ab ac
echo xx xb xc
xx xb xc
+1 -1
View File
@@ -86,7 +86,7 @@ unset HISTFILE
fc -l 4
fc -l 4 8
# no longer an out-of-range error
# now an out-of-range error because of the one=two not found in history
fc -l one=two three=four 502
history 4
+18 -2
View File
@@ -1958,6 +1958,22 @@ initialize_dynamic_variables ()
/* */
/* **************************************************************** */
#if 0 /* not yet */
int
var_isset (var)
SHELL_VAR *var;
{
return (var->value != 0);
}
int
var_isunset (var)
SHELL_VAR *var;
{
return (var->value == 0);
}
#endif
/* How to get a pointer to the shell variable or function named NAME.
HASHED_VARS is a pointer to the hash table containing the list
of interest (either variables or functions). */
@@ -2731,7 +2747,7 @@ set_local_var_flags:
/* value_cell will be 0 if localvar_inherit == 0 or there was no old variable
with the same name or the old variable was invisible */
if (was_tmpvar == 0 && no_invisible_vars == 0 && value_cell (new_var) == 0)
if (was_tmpvar == 0 && value_cell (new_var) == 0)
VSETATTR (new_var, att_invisible); /* XXX */
return (new_var);
}
@@ -4032,7 +4048,7 @@ delete_all_variables (hashed_vars)
if (!entry) \
{ \
entry = bind_variable (name, "", 0); \
if (!no_invisible_vars && entry) entry->attributes |= att_invisible; \
if (entry) entry->attributes |= att_invisible; \
} \
} \
while (0)