renamed several functions beginning with legal_; changed all callers

This commit is contained in:
Chet Ramey
2023-11-06 09:26:02 -05:00
parent fe24a6a55e
commit b30389070a
57 changed files with 3622 additions and 3516 deletions
+18
View File
@@ -7928,3 +7928,21 @@ general.c
- legal_number: use the same test (isspace(3)) to skip trailing
whitespace that strtoimax uses to skip leading whitespace.
Report and patch from Paul Eggert <eggert@cs.ucla.edu>
general.c,general.h
- legal_number: renamed to valid_number, changed all callers
- legal_identifier: renamed to valid_identifier, changed all callers
- legal_alias_name: renamed to valid_alias_name, changed all callers
lib/sh/compat.c
- legal_number: definition of legal_number here for backwards compat
with old loadable builtins
- legal_identifier: definition of legal_identifier here for backwards
compat with old loadable builtins
- legal_alias_name: same
subst.c
- brace_expand_word_list: if brace_expand returns NULL, dummy up a
single-element vector with a copy of the original word so we can
add it to the result list unchanged.
Inspired by https://savannah.gnu.org/support/?110948
+1
View File
@@ -433,6 +433,7 @@ lib/sh/anonfile.c f
lib/sh/casemod.c f
lib/sh/clktck.c f
lib/sh/clock.c f
lib/sh/compat.c f
lib/sh/dprintf.c f
lib/sh/eaccess.c f
lib/sh/fmtullong.c f
+2 -1
View File
@@ -245,7 +245,8 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/shmbchar.c ${SH_LIBSRC}/utf8.c \
${SH_LIBSRC}/random.c ${SH_LIBSRC}/gettimeofday.c \
${SH_LIBSRC}/timers.c ${SH_LIBSRC}/strvis.c \
${SH_LIBSRC}/strlcpy.c ${SH_LIBSRC}/strscpy.c
${SH_LIBSRC}/strlcpy.c ${SH_LIBSRC}/strscpy.c \
${SH_LIBSRC}/compat.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
+1 -1
View File
@@ -1294,7 +1294,7 @@ tokenize_array_reference (const char *name, int flags, char **subp)
if (t)
{
*t = '\0';
r = legal_identifier (name);
r = valid_identifier (name);
if (flags & VA_NOEXPAND) /* Don't waste a lookup if we don't need one */
isassoc = (entry = find_variable (name)) && assoc_p (entry);
*t = '[';
+2 -2
View File
@@ -4559,11 +4559,11 @@ bash_execute_unix_command (int count, int key)
maybe_make_readline_line (v ? value_cell (v) : 0);
v = find_variable ("READLINE_POINT");
if (v && legal_number (value_cell (v), &mi))
if (v && valid_number (value_cell (v), &mi))
readline_set_char_offset (mi, &rl_point);
v = find_variable ("READLINE_MARK");
if (v && legal_number (value_cell (v), &mi))
if (v && valid_number (value_cell (v), &mi))
readline_set_char_offset (mi, &rl_mark);
unbind_readline_variables ();
+1 -1
View File
@@ -481,7 +481,7 @@ expand_seqterm (char *text, size_t tlen)
/* Now figure out whether LHS and RHS are integers or letters. Both
sides have to match. */
lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
lhs_t = (valid_number (lhs, &tl)) ? ST_INT :
((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);
/* Decide on rhs and whether or not it looks like the user specified
+2 -2
View File
@@ -1,7 +1,7 @@
This file is alias.def, from which is created alias.c
It implements the builtins "alias" and "unalias" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -126,7 +126,7 @@ alias_builtin (WORD_LIST *list)
name[offset] = '\0';
value = name + offset + 1;
if (legal_alias_name (name, 0) == 0)
if (valid_alias_name (name, 0) == 0)
{
builtin_error (_("`%s': invalid alias name"), name);
any_failed++;
+1 -1
View File
@@ -152,7 +152,7 @@ internal_getopt(WORD_LIST *list, char *opts)
list_optflags = 0;
}
} else {
if (lcurrent->next && legal_number(lcurrent->next->word->word, (intmax_t *)0)) {
if (lcurrent->next && valid_number(lcurrent->next->word->word, (intmax_t *)0)) {
lcurrent = lcurrent->next;
list_optarg = lcurrent->word->word;
list_optflags = lcurrent->word->flags;
+2 -2
View File
@@ -2,7 +2,7 @@ This file is caller.def, from which is created caller.c. It implements the
builtin "caller" in Bash.
Copyright (C) 2002-2008 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2019,2022 Free Software Foundation, Inc.
Copyright (C) 2008-2019,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -108,7 +108,7 @@ caller_builtin (WORD_LIST *list)
if (funcname_a == 0 || array_empty (funcname_a))
return (EXECUTION_FAILURE);
if (legal_number (list->word->word, &num))
if (valid_number (list->word->word, &num))
{
lineno_s = array_reference (bash_lineno_a, num);
source_s = array_reference (bash_source_a, num+1);
+4 -4
View File
@@ -491,7 +491,7 @@ get_numeric_arg (WORD_LIST *list, int fatal, intmax_t *count)
if (list)
{
arg = list->word->word;
if (arg == 0 || (legal_number (arg, count) == 0))
if (arg == 0 || (valid_number (arg, count) == 0))
{
sh_neednumarg (list->word->word ? list->word->word : "`'");
if (fatal == 0)
@@ -535,7 +535,7 @@ get_exitstat (WORD_LIST *list)
}
arg = list->word->word;
if (arg == 0 || legal_number (arg, &sval) == 0)
if (arg == 0 || valid_number (arg, &sval) == 0)
{
sh_neednumarg (list->word->word ? list->word->word : "`'");
return EX_USAGE;
@@ -770,7 +770,7 @@ display_signal_list (WORD_LIST *list, int forcecols)
/* List individual signal names or numbers. */
while (list)
{
if (legal_number (list->word->word, &lsignum))
if (valid_number (list->word->word, &lsignum))
{
/* This is specified by Posix.2 so that exit statuses can be
mapped into signal numbers. */
@@ -969,7 +969,7 @@ builtin_find_indexed_array (char *array_name, int flags)
{
SHELL_VAR *entry;
if ((flags & 2) && legal_identifier (array_name) == 0)
if ((flags & 2) && valid_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (SHELL_VAR *)NULL;
+1 -1
View File
@@ -349,7 +349,7 @@ build_actions (WORD_LIST *list, struct _optflags *flagp, unsigned long *actp, un
if (vnamep)
{
*vnamep = list_optarg;
if (legal_identifier (list_optarg) == 0)
if (valid_identifier (list_optarg) == 0)
{
sh_invalidid (list_optarg);
return (EX_USAGE);
+2 -2
View File
@@ -450,7 +450,7 @@ declare_internal (WORD_LIST *list, int local_var)
/* Should we restrict this when the shell is in posix mode even if
the function was created before the shell entered posix mode?
Previous versions of the shell enforced the restriction. */
if (posixly_correct && legal_identifier (name) == 0)
if (posixly_correct && valid_identifier (name) == 0)
{
sh_invalidid (name);
assign_error++;
@@ -577,7 +577,7 @@ restart_new_var_name:
#endif
/* Ensure the argument is a valid, well-formed shell identifier. */
if (legal_identifier (name) == 0)
if (valid_identifier (name) == 0)
{
sh_invalidid (name);
assign_error++;
+1 -1
View File
@@ -554,7 +554,7 @@ fc_number (WORD_LIST *list)
s = list->word->word;
if (*s == '-')
s++;
return (legal_number (s, (intmax_t *)NULL));
return (valid_number (s, (intmax_t *)NULL));
}
/* Return an absolute index into HLIST which corresponds to COMMAND. If
+1 -1
View File
@@ -114,7 +114,7 @@ getopts_bind_variable (char *name, char *value)
{
SHELL_VAR *v;
if (legal_identifier (name))
if (valid_identifier (name))
{
v = bind_variable (name, value, 0);
if (v && (readonly_p (v) || noassign_p (v)))
+3 -3
View File
@@ -1,7 +1,7 @@
This file is history.def, from which is created history.c.
It implements the builtin "history" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -187,7 +187,7 @@ history_builtin (WORD_LIST *list)
{
intmax_t delete_start, delete_end;
*range++ = '\0';
if (legal_number (delete_arg, &delete_start) == 0 || legal_number (range, &delete_end) == 0)
if (valid_number (delete_arg, &delete_start) == 0 || valid_number (range, &delete_end) == 0)
{
range[-1] = '-';
sh_erange (delete_arg, _("history position"));
@@ -224,7 +224,7 @@ history_builtin (WORD_LIST *list)
}
else if (flags & DFLAG)
{
if (legal_number (delete_arg, &delete_offset) == 0)
if (valid_number (delete_arg, &delete_offset) == 0)
{
sh_invalidnum (delete_arg);
return (EXECUTION_FAILURE);
+1 -1
View File
@@ -280,7 +280,7 @@ disown_builtin (WORD_LIST *list)
do
{
BLOCK_CHILD (set, oset);
job = (list && legal_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value)
job = (list && valid_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value)
? get_job_by_pid ((pid_t) pid_value, 0, 0)
: get_job_spec (list);
+2 -2
View File
@@ -1,7 +1,7 @@
This file is kill.def, from which is created kill.c.
It implements the builtin "kill" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -189,7 +189,7 @@ use_sigspec:
word++;
/* Use the entire argument in case of minus sign presence. */
if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
if (*word && valid_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
{
pid = (pid_t) pid_value;
+6 -6
View File
@@ -243,7 +243,7 @@ mapfile_builtin (WORD_LIST *list)
delim = *list_optarg;
break;
case 'u':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
builtin_error (_("%s: invalid file descriptor specification"), list_optarg);
@@ -260,7 +260,7 @@ mapfile_builtin (WORD_LIST *list)
break;
case 'n':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (unsigned)intval)
{
builtin_error (_("%s: invalid line count"), list_optarg);
@@ -271,7 +271,7 @@ mapfile_builtin (WORD_LIST *list)
break;
case 'O':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (unsigned)intval)
{
builtin_error (_("%s: invalid array origin"), list_optarg);
@@ -288,7 +288,7 @@ mapfile_builtin (WORD_LIST *list)
callback = list_optarg;
break;
case 'c':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval <= 0 || intval != (unsigned)intval)
{
builtin_error (_("%s: invalid callback quantum"), list_optarg);
@@ -298,7 +298,7 @@ mapfile_builtin (WORD_LIST *list)
callback_quantum = intval;
break;
case 's':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (unsigned)intval)
{
builtin_error (_("%s: invalid line count"), list_optarg);
@@ -330,7 +330,7 @@ mapfile_builtin (WORD_LIST *list)
else
array_name = list->word->word;
if (legal_identifier (array_name) == 0)
if (valid_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (EXECUTION_FAILURE);
+3 -3
View File
@@ -287,9 +287,9 @@ printf_builtin (WORD_LIST *list)
bindflags = 0;
#if defined (ARRAY_VARS)
SET_VFLAGS (list_optflags, arrayflags, bindflags);
retval = legal_identifier (vname) || valid_array_reference (vname, arrayflags);
retval = valid_identifier (vname) || valid_array_reference (vname, arrayflags);
#else
retval = legal_identifier (vname);
retval = valid_identifier (vname);
#endif
if (retval)
{
@@ -644,7 +644,7 @@ printf_builtin (WORD_LIST *list)
var = getstr ();
if (var && *var)
{
if (legal_identifier (var))
if (valid_identifier (var))
bind_var_to_int (var, tw, 0);
else
{
+6 -6
View File
@@ -1,7 +1,7 @@
This file is pushd.def, from which is created pushd.c. It implements the
builtins "pushd", "popd", and "dirs" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -227,7 +227,7 @@ pushd_builtin (WORD_LIST *list)
break;
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &num) == 0)
if (valid_number (list->word->word + 1, &num) == 0)
{
sh_invalidnum (list->word->word);
builtin_usage ();
@@ -339,7 +339,7 @@ popd_builtin (WORD_LIST *list)
}
else if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &which) == 0)
if (valid_number (list->word->word + 1, &which) == 0)
{
sh_invalidnum (list->word->word);
builtin_usage ();
@@ -370,7 +370,7 @@ popd_builtin (WORD_LIST *list)
{
if (((direction = list->word->word[0]) == '+') || direction == '-')
{
if (legal_number (list->word->word + 1, &which) == 0)
if (valid_number (list->word->word + 1, &which) == 0)
{
sh_invalidnum (list->word->word);
builtin_usage ();
@@ -461,7 +461,7 @@ dirs_builtin (WORD_LIST *list)
else if (*list->word->word == '+' || *list->word->word == '-')
{
int sign;
if (legal_number (w = list->word->word + 1, &i) == 0)
if (valid_number (w = list->word->word + 1, &i) == 0)
{
sh_invalidnum (list->word->word);
builtin_usage ();
@@ -628,7 +628,7 @@ get_dirstack_from_string (char *string)
sign = (*string == '-') ? -1 : 1;
string++;
}
if (legal_number (string, &i) == 0)
if (valid_number (string, &i) == 0)
return ((char *)NULL);
index_flag = 0;
+8 -8
View File
@@ -344,7 +344,7 @@ read_builtin (WORD_LIST *list)
delim = -1;
case 'n':
nflag = 1;
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
sh_invalidnum (list_optarg);
@@ -354,7 +354,7 @@ read_builtin (WORD_LIST *list)
nchars = intval;
break;
case 'u':
code = legal_number (list_optarg, &intval);
code = valid_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
builtin_error (_("%s: invalid file descriptor specification"), list_optarg);
@@ -389,10 +389,10 @@ read_builtin (WORD_LIST *list)
#if defined (ARRAY_VARS)
if (list)
SET_VFLAGS (list->word->flags, vflags, bindflags);
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
if (list && valid_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
#else
bindflags = 0;
if (list && legal_identifier (list->word->word) == 0)
if (list && valid_identifier (list->word->word) == 0)
#endif
{
sh_invalidid (list->word->word);
@@ -988,9 +988,9 @@ assign_vars:
varname = list->word->word;
#if defined (ARRAY_VARS)
SET_VFLAGS (list->word->flags, vflags, bindflags);
if (legal_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0)
if (valid_identifier (varname) == 0 && valid_array_reference (varname, vflags) == 0)
#else
if (legal_identifier (varname) == 0)
if (valid_identifier (varname) == 0)
#endif
{
sh_invalidid (varname);
@@ -1037,9 +1037,9 @@ assign_vars:
/* Now assign the rest of the line to the last variable argument. */
#if defined (ARRAY_VARS)
SET_VFLAGS (list->word->flags, vflags, bindflags);
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
if (valid_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
#else
if (legal_identifier (list->word->word) == 0)
if (valid_identifier (list->word->word) == 0)
#endif
{
sh_invalidid (list->word->word);
+1 -1
View File
@@ -897,7 +897,7 @@ unset_builtin (WORD_LIST *list)
/* Get error checking out of the way first. The low-level functions
just perform the unset, relying on the caller to verify. */
valid_id = legal_identifier (name);
valid_id = valid_identifier (name);
/* Whether or not we are in posix mode, if neither -f nor -v appears,
skip over trying to unset variables with invalid names and just
+1 -1
View File
@@ -211,7 +211,7 @@ set_or_show_attributes (WORD_LIST *list, int attribute, int nodefs)
}
}
if (legal_identifier (name) == 0)
if (valid_identifier (name) == 0)
{
sh_invalidid (name);
if (assign)
+4 -4
View File
@@ -153,10 +153,10 @@ wait_builtin (WORD_LIST *list)
int arrayflags;
SET_VFLAGS (vflags, arrayflags, bindflags);
if (legal_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0)
if (valid_identifier (vname) == 0 && valid_array_reference (vname, arrayflags) == 0)
#else
bindflags = 0;
if (legal_identifier (vname) == 0)
if (valid_identifier (vname) == 0)
#endif
{
sh_invalidid (vname);
@@ -254,7 +254,7 @@ wait_builtin (WORD_LIST *list)
w = list->word->word;
if (DIGIT (*w))
{
if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value)
if (valid_number (w, &pid_value) && pid_value == (pid_t)pid_value)
{
pid = (pid_t)pid_value;
status = wait_for_single_pid (pid, wflags|JWAIT_PERROR);
@@ -342,7 +342,7 @@ set_waitlist (WORD_LIST *list)
for (l = list; l; l = l->next)
{
job = NO_JOB;
job = (l && legal_number (l->word->word, &pid) && pid == (pid_t) pid)
job = (l && valid_number (l->word->word, &pid) && pid == (pid_t) pid)
? get_job_by_pid ((pid_t) pid, 0, 0)
: get_job_spec (l);
if (job == NO_JOB || jobs == 0 || INVALID_JOB (job))
+3090 -3089
View File
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -5,14 +5,14 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Wed Oct 11 10:23:34 EDT 2023
.\" Last Change: Wed Nov 1 09:34:21 EDT 2023
.\"
.\" bash_builtins, strip all but Built-Ins section
.\" avoid a warning about an undefined register
.\" .if !rzY .nr zY 0
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2023 October 6" "GNU Bash 5.3"
.TH BASH 1 "2023 November 1" "GNU Bash 5.3"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -151,7 +151,9 @@ A
signals the end of options and disables further option processing.
Any arguments after the
.B \-\-
are treated as filenames and arguments. An argument of
are treated as a shell script filename (see below)
and arguments passed to that script.
An argument of
.B \-
is equivalent to \fB\-\-\fP.
.PD
@@ -255,7 +257,7 @@ If arguments remain after option processing, and neither the
nor the
.B \-s
option has been supplied, the first argument is assumed to
be the name of a file containing shell commands.
be the name of a file containing shell commands (a \fIshell script\fP).
If
.B bash
is invoked in this fashion,
+144 -140
View File
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 6.8 from bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 6 October 2023).
Bash shell (version 5.3, 1 November 2023).
This is Edition 5.3, last updated 6 October 2023, of 'The GNU Bash
This is Edition 5.3, last updated 1 November 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@@ -26,10 +26,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 6 October 2023). The Bash home page is
Bash shell (version 5.3, 1 November 2023). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 6 October 2023, of 'The GNU Bash
This is Edition 5.3, last updated 1 November 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -6247,8 +6247,12 @@ invocation which are not available with the 'set' builtin.
'--'
A '--' signals the end of options and disables further option
processing. Any arguments after the '--' are treated as filenames
and arguments.
processing. Any arguments after the '--' are treated as a shell
script filename (*note Shell Scripts::) and arguments passed to
that script.
'-'
Equivalent to '--'.
A _login_ shell is one whose first character of argument zero is '-',
or one invoked with the '--login' option.
@@ -12796,7 +12800,7 @@ D.5 Concept Index
* installation: Basic Installation. (line 6)
* interaction, readline: Readline Interaction.
(line 6)
* interactive shell: Invoking Bash. (line 132)
* interactive shell: Invoking Bash. (line 136)
* interactive shell <1>: Interactive Shells. (line 6)
* internationalization: Locale Translation. (line 6)
* internationalized scripts: Creating Internationalized Scripts.
@@ -12809,7 +12813,7 @@ D.5 Concept Index
* killing text: Readline Killing Commands.
(line 6)
* localization: Locale Translation. (line 6)
* login shell: Invoking Bash. (line 129)
* login shell: Invoking Bash. (line 133)
* matching, pattern: Pattern Matching. (line 6)
* metacharacter: Definitions. (line 46)
* name: Definitions. (line 51)
@@ -12875,138 +12879,138 @@ D.5 Concept Index

Tag Table:
Node: Top890
Node: Introduction2803
Node: What is Bash?3016
Node: What is a shell?4127
Node: Definitions6662
Node: Basic Shell Features9610
Node: Shell Syntax10826
Node: Shell Operation11849
Node: Quoting13139
Node: Escape Character14440
Node: Single Quotes14922
Node: Double Quotes15267
Node: ANSI-C Quoting16542
Node: Locale Translation17851
Node: Creating Internationalized Scripts19159
Node: Comments23273
Node: Shell Commands23888
Node: Reserved Words24823
Node: Simple Commands25576
Node: Pipelines26227
Node: Lists29210
Node: Compound Commands31002
Node: Looping Constructs32011
Node: Conditional Constructs34503
Node: Command Grouping48988
Node: Coprocesses50463
Node: GNU Parallel53123
Node: Shell Functions54037
Node: Shell Parameters61919
Node: Positional Parameters66304
Node: Special Parameters67203
Node: Shell Expansions70414
Node: Brace Expansion72499
Node: Tilde Expansion75230
Node: Shell Parameter Expansion77848
Node: Command Substitution96438
Node: Arithmetic Expansion99899
Node: Process Substitution100864
Node: Word Splitting101981
Node: Filename Expansion104026
Node: Pattern Matching106956
Node: Quote Removal111955
Node: Redirections112247
Node: Executing Commands121938
Node: Simple Command Expansion122605
Node: Command Search and Execution124712
Node: Command Execution Environment127096
Node: Environment130128
Node: Exit Status131788
Node: Signals133569
Node: Shell Scripts137015
Node: Shell Builtin Commands140039
Node: Bourne Shell Builtins142074
Node: Bash Builtins165463
Node: Modifying Shell Behavior198399
Node: The Set Builtin198741
Node: The Shopt Builtin209712
Node: Special Builtins225847
Node: Shell Variables226823
Node: Bourne Shell Variables227257
Node: Bash Variables229358
Node: Bash Features264423
Node: Invoking Bash265433
Node: Bash Startup Files271469
Node: Interactive Shells276597
Node: What is an Interactive Shell?277005
Node: Is this Shell Interactive?277651
Node: Interactive Shell Behavior278463
Node: Bash Conditional Expressions282089
Node: Shell Arithmetic286999
Node: Aliases289957
Node: Arrays292848
Node: The Directory Stack299479
Node: Directory Stack Builtins300260
Node: Controlling the Prompt304517
Node: The Restricted Shell307479
Node: Bash POSIX Mode310086
Node: Shell Compatibility Mode326340
Node: Job Control334585
Node: Job Control Basics335042
Node: Job Control Builtins340041
Node: Job Control Variables345833
Node: Command Line Editing346986
Node: Introduction and Notation348654
Node: Readline Interaction350274
Node: Readline Bare Essentials351462
Node: Readline Movement Commands353248
Node: Readline Killing Commands354205
Node: Readline Arguments356123
Node: Searching357164
Node: Readline Init File359347
Node: Readline Init File Syntax360605
Node: Conditional Init Constructs384627
Node: Sample Init File388820
Node: Bindable Readline Commands391941
Node: Commands For Moving393142
Node: Commands For History395190
Node: Commands For Text400181
Node: Commands For Killing404156
Node: Numeric Arguments406857
Node: Commands For Completion407993
Node: Keyboard Macros412181
Node: Miscellaneous Commands412866
Node: Readline vi Mode418901
Node: Programmable Completion419805
Node: Programmable Completion Builtins427582
Node: A Programmable Completion Example438699
Node: Using History Interactively443944
Node: Bash History Facilities444625
Node: Bash History Builtins447633
Node: History Interaction452721
Node: Event Designators456531
Node: Word Designators458066
Node: Modifiers459928
Node: Installing Bash461733
Node: Basic Installation462867
Node: Compilers and Options466586
Node: Compiling For Multiple Architectures467324
Node: Installation Names469013
Node: Specifying the System Type471119
Node: Sharing Defaults471833
Node: Operation Controls472503
Node: Optional Features473458
Node: Reporting Bugs484674
Node: Major Differences From The Bourne Shell486005
Node: GNU Free Documentation License502860
Node: Indexes528034
Node: Builtin Index528485
Node: Reserved Word Index535583
Node: Variable Index538028
Node: Function Index555159
Node: Concept Index568877
Node: Top892
Node: Introduction2807
Node: What is Bash?3020
Node: What is a shell?4131
Node: Definitions6666
Node: Basic Shell Features9614
Node: Shell Syntax10830
Node: Shell Operation11853
Node: Quoting13143
Node: Escape Character14444
Node: Single Quotes14926
Node: Double Quotes15271
Node: ANSI-C Quoting16546
Node: Locale Translation17855
Node: Creating Internationalized Scripts19163
Node: Comments23277
Node: Shell Commands23892
Node: Reserved Words24827
Node: Simple Commands25580
Node: Pipelines26231
Node: Lists29214
Node: Compound Commands31006
Node: Looping Constructs32015
Node: Conditional Constructs34507
Node: Command Grouping48992
Node: Coprocesses50467
Node: GNU Parallel53127
Node: Shell Functions54041
Node: Shell Parameters61923
Node: Positional Parameters66308
Node: Special Parameters67207
Node: Shell Expansions70418
Node: Brace Expansion72503
Node: Tilde Expansion75234
Node: Shell Parameter Expansion77852
Node: Command Substitution96442
Node: Arithmetic Expansion99903
Node: Process Substitution100868
Node: Word Splitting101985
Node: Filename Expansion104030
Node: Pattern Matching106960
Node: Quote Removal111959
Node: Redirections112251
Node: Executing Commands121942
Node: Simple Command Expansion122609
Node: Command Search and Execution124716
Node: Command Execution Environment127100
Node: Environment130132
Node: Exit Status131792
Node: Signals133573
Node: Shell Scripts137019
Node: Shell Builtin Commands140043
Node: Bourne Shell Builtins142078
Node: Bash Builtins165467
Node: Modifying Shell Behavior198403
Node: The Set Builtin198745
Node: The Shopt Builtin209716
Node: Special Builtins225851
Node: Shell Variables226827
Node: Bourne Shell Variables227261
Node: Bash Variables229362
Node: Bash Features264427
Node: Invoking Bash265437
Node: Bash Startup Files271568
Node: Interactive Shells276696
Node: What is an Interactive Shell?277104
Node: Is this Shell Interactive?277750
Node: Interactive Shell Behavior278562
Node: Bash Conditional Expressions282188
Node: Shell Arithmetic287098
Node: Aliases290056
Node: Arrays292947
Node: The Directory Stack299578
Node: Directory Stack Builtins300359
Node: Controlling the Prompt304616
Node: The Restricted Shell307578
Node: Bash POSIX Mode310185
Node: Shell Compatibility Mode326439
Node: Job Control334684
Node: Job Control Basics335141
Node: Job Control Builtins340140
Node: Job Control Variables345932
Node: Command Line Editing347085
Node: Introduction and Notation348753
Node: Readline Interaction350373
Node: Readline Bare Essentials351561
Node: Readline Movement Commands353347
Node: Readline Killing Commands354304
Node: Readline Arguments356222
Node: Searching357263
Node: Readline Init File359446
Node: Readline Init File Syntax360704
Node: Conditional Init Constructs384726
Node: Sample Init File388919
Node: Bindable Readline Commands392040
Node: Commands For Moving393241
Node: Commands For History395289
Node: Commands For Text400280
Node: Commands For Killing404255
Node: Numeric Arguments406956
Node: Commands For Completion408092
Node: Keyboard Macros412280
Node: Miscellaneous Commands412965
Node: Readline vi Mode419000
Node: Programmable Completion419904
Node: Programmable Completion Builtins427681
Node: A Programmable Completion Example438798
Node: Using History Interactively444043
Node: Bash History Facilities444724
Node: Bash History Builtins447732
Node: History Interaction452820
Node: Event Designators456630
Node: Word Designators458165
Node: Modifiers460027
Node: Installing Bash461832
Node: Basic Installation462966
Node: Compilers and Options466685
Node: Compiling For Multiple Architectures467423
Node: Installation Names469112
Node: Specifying the System Type471218
Node: Sharing Defaults471932
Node: Operation Controls472602
Node: Optional Features473557
Node: Reporting Bugs484773
Node: Major Differences From The Bourne Shell486104
Node: GNU Free Documentation License502959
Node: Indexes528133
Node: Builtin Index528584
Node: Reserved Word Index535682
Node: Variable Index538127
Node: Function Index555258
Node: Concept Index568976

End Tag Table
+144 -140
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.8 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 6 October 2023).
Bash shell (version 5.3, 1 November 2023).
This is Edition 5.3, last updated 6 October 2023, of 'The GNU Bash
This is Edition 5.3, last updated 1 November 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 6 October 2023). The Bash home page is
Bash shell (version 5.3, 1 November 2023). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 6 October 2023, of 'The GNU Bash
This is Edition 5.3, last updated 1 November 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -6248,8 +6248,12 @@ invocation which are not available with the 'set' builtin.
'--'
A '--' signals the end of options and disables further option
processing. Any arguments after the '--' are treated as filenames
and arguments.
processing. Any arguments after the '--' are treated as a shell
script filename (*note Shell Scripts::) and arguments passed to
that script.
'-'
Equivalent to '--'.
A _login_ shell is one whose first character of argument zero is '-',
or one invoked with the '--login' option.
@@ -12797,7 +12801,7 @@ D.5 Concept Index
* installation: Basic Installation. (line 6)
* interaction, readline: Readline Interaction.
(line 6)
* interactive shell: Invoking Bash. (line 132)
* interactive shell: Invoking Bash. (line 136)
* interactive shell <1>: Interactive Shells. (line 6)
* internationalization: Locale Translation. (line 6)
* internationalized scripts: Creating Internationalized Scripts.
@@ -12810,7 +12814,7 @@ D.5 Concept Index
* killing text: Readline Killing Commands.
(line 6)
* localization: Locale Translation. (line 6)
* login shell: Invoking Bash. (line 129)
* login shell: Invoking Bash. (line 133)
* matching, pattern: Pattern Matching. (line 6)
* metacharacter: Definitions. (line 46)
* name: Definitions. (line 51)
@@ -12876,138 +12880,138 @@ D.5 Concept Index

Tag Table:
Node: Top893
Node: Introduction2809
Node: What is Bash?3025
Node: What is a shell?4139
Node: Definitions6677
Node: Basic Shell Features9628
Node: Shell Syntax10847
Node: Shell Operation11873
Node: Quoting13166
Node: Escape Character14470
Node: Single Quotes14955
Node: Double Quotes15303
Node: ANSI-C Quoting16581
Node: Locale Translation17893
Node: Creating Internationalized Scripts19204
Node: Comments23321
Node: Shell Commands23939
Node: Reserved Words24877
Node: Simple Commands25633
Node: Pipelines26287
Node: Lists29273
Node: Compound Commands31068
Node: Looping Constructs32080
Node: Conditional Constructs34575
Node: Command Grouping49063
Node: Coprocesses50541
Node: GNU Parallel53204
Node: Shell Functions54121
Node: Shell Parameters62006
Node: Positional Parameters66394
Node: Special Parameters67296
Node: Shell Expansions70510
Node: Brace Expansion72598
Node: Tilde Expansion75332
Node: Shell Parameter Expansion77953
Node: Command Substitution96546
Node: Arithmetic Expansion100010
Node: Process Substitution100978
Node: Word Splitting102098
Node: Filename Expansion104146
Node: Pattern Matching107079
Node: Quote Removal112081
Node: Redirections112376
Node: Executing Commands122070
Node: Simple Command Expansion122740
Node: Command Search and Execution124850
Node: Command Execution Environment127237
Node: Environment130272
Node: Exit Status131935
Node: Signals133719
Node: Shell Scripts137168
Node: Shell Builtin Commands140195
Node: Bourne Shell Builtins142233
Node: Bash Builtins165625
Node: Modifying Shell Behavior198564
Node: The Set Builtin198909
Node: The Shopt Builtin209883
Node: Special Builtins226021
Node: Shell Variables227000
Node: Bourne Shell Variables227437
Node: Bash Variables229541
Node: Bash Features264609
Node: Invoking Bash265622
Node: Bash Startup Files271661
Node: Interactive Shells276792
Node: What is an Interactive Shell?277203
Node: Is this Shell Interactive?277852
Node: Interactive Shell Behavior278667
Node: Bash Conditional Expressions282296
Node: Shell Arithmetic287209
Node: Aliases290170
Node: Arrays293064
Node: The Directory Stack299698
Node: Directory Stack Builtins300482
Node: Controlling the Prompt304742
Node: The Restricted Shell307707
Node: Bash POSIX Mode310317
Node: Shell Compatibility Mode326574
Node: Job Control334822
Node: Job Control Basics335282
Node: Job Control Builtins340284
Node: Job Control Variables346079
Node: Command Line Editing347235
Node: Introduction and Notation348906
Node: Readline Interaction350529
Node: Readline Bare Essentials351720
Node: Readline Movement Commands353509
Node: Readline Killing Commands354469
Node: Readline Arguments356390
Node: Searching357434
Node: Readline Init File359620
Node: Readline Init File Syntax360881
Node: Conditional Init Constructs384906
Node: Sample Init File389102
Node: Bindable Readline Commands392226
Node: Commands For Moving393430
Node: Commands For History395481
Node: Commands For Text400475
Node: Commands For Killing404453
Node: Numeric Arguments407157
Node: Commands For Completion408296
Node: Keyboard Macros412487
Node: Miscellaneous Commands413175
Node: Readline vi Mode419213
Node: Programmable Completion420120
Node: Programmable Completion Builtins427900
Node: A Programmable Completion Example439020
Node: Using History Interactively444268
Node: Bash History Facilities444952
Node: Bash History Builtins447963
Node: History Interaction453054
Node: Event Designators456867
Node: Word Designators458405
Node: Modifiers460270
Node: Installing Bash462078
Node: Basic Installation463215
Node: Compilers and Options466937
Node: Compiling For Multiple Architectures467678
Node: Installation Names469370
Node: Specifying the System Type471479
Node: Sharing Defaults472196
Node: Operation Controls472869
Node: Optional Features473827
Node: Reporting Bugs485046
Node: Major Differences From The Bourne Shell486380
Node: GNU Free Documentation License503238
Node: Indexes528415
Node: Builtin Index528869
Node: Reserved Word Index535970
Node: Variable Index538418
Node: Function Index555552
Node: Concept Index569273
Node: Top895
Node: Introduction2813
Node: What is Bash?3029
Node: What is a shell?4143
Node: Definitions6681
Node: Basic Shell Features9632
Node: Shell Syntax10851
Node: Shell Operation11877
Node: Quoting13170
Node: Escape Character14474
Node: Single Quotes14959
Node: Double Quotes15307
Node: ANSI-C Quoting16585
Node: Locale Translation17897
Node: Creating Internationalized Scripts19208
Node: Comments23325
Node: Shell Commands23943
Node: Reserved Words24881
Node: Simple Commands25637
Node: Pipelines26291
Node: Lists29277
Node: Compound Commands31072
Node: Looping Constructs32084
Node: Conditional Constructs34579
Node: Command Grouping49067
Node: Coprocesses50545
Node: GNU Parallel53208
Node: Shell Functions54125
Node: Shell Parameters62010
Node: Positional Parameters66398
Node: Special Parameters67300
Node: Shell Expansions70514
Node: Brace Expansion72602
Node: Tilde Expansion75336
Node: Shell Parameter Expansion77957
Node: Command Substitution96550
Node: Arithmetic Expansion100014
Node: Process Substitution100982
Node: Word Splitting102102
Node: Filename Expansion104150
Node: Pattern Matching107083
Node: Quote Removal112085
Node: Redirections112380
Node: Executing Commands122074
Node: Simple Command Expansion122744
Node: Command Search and Execution124854
Node: Command Execution Environment127241
Node: Environment130276
Node: Exit Status131939
Node: Signals133723
Node: Shell Scripts137172
Node: Shell Builtin Commands140199
Node: Bourne Shell Builtins142237
Node: Bash Builtins165629
Node: Modifying Shell Behavior198568
Node: The Set Builtin198913
Node: The Shopt Builtin209887
Node: Special Builtins226025
Node: Shell Variables227004
Node: Bourne Shell Variables227441
Node: Bash Variables229545
Node: Bash Features264613
Node: Invoking Bash265626
Node: Bash Startup Files271760
Node: Interactive Shells276891
Node: What is an Interactive Shell?277302
Node: Is this Shell Interactive?277951
Node: Interactive Shell Behavior278766
Node: Bash Conditional Expressions282395
Node: Shell Arithmetic287308
Node: Aliases290269
Node: Arrays293163
Node: The Directory Stack299797
Node: Directory Stack Builtins300581
Node: Controlling the Prompt304841
Node: The Restricted Shell307806
Node: Bash POSIX Mode310416
Node: Shell Compatibility Mode326673
Node: Job Control334921
Node: Job Control Basics335381
Node: Job Control Builtins340383
Node: Job Control Variables346178
Node: Command Line Editing347334
Node: Introduction and Notation349005
Node: Readline Interaction350628
Node: Readline Bare Essentials351819
Node: Readline Movement Commands353608
Node: Readline Killing Commands354568
Node: Readline Arguments356489
Node: Searching357533
Node: Readline Init File359719
Node: Readline Init File Syntax360980
Node: Conditional Init Constructs385005
Node: Sample Init File389201
Node: Bindable Readline Commands392325
Node: Commands For Moving393529
Node: Commands For History395580
Node: Commands For Text400574
Node: Commands For Killing404552
Node: Numeric Arguments407256
Node: Commands For Completion408395
Node: Keyboard Macros412586
Node: Miscellaneous Commands413274
Node: Readline vi Mode419312
Node: Programmable Completion420219
Node: Programmable Completion Builtins427999
Node: A Programmable Completion Example439119
Node: Using History Interactively444367
Node: Bash History Facilities445051
Node: Bash History Builtins448062
Node: History Interaction453153
Node: Event Designators456966
Node: Word Designators458504
Node: Modifiers460369
Node: Installing Bash462177
Node: Basic Installation463314
Node: Compilers and Options467036
Node: Compiling For Multiple Architectures467777
Node: Installation Names469469
Node: Specifying the System Type471578
Node: Sharing Defaults472295
Node: Operation Controls472968
Node: Optional Features473926
Node: Reporting Bugs485145
Node: Major Differences From The Bourne Shell486479
Node: GNU Free Documentation License503337
Node: Indexes528514
Node: Builtin Index528968
Node: Reserved Word Index536069
Node: Variable Index538517
Node: Function Index555651
Node: Concept Index569372

End Tag Table
+7 -1
View File
@@ -7247,7 +7247,13 @@ that may be reused as input.
@item --
A @code{--} signals the end of options and disables further option
processing.
Any arguments after the @code{--} are treated as filenames and arguments.
Any arguments after the @code{--}
are treated as a shell script filename (@pxref{Shell Scripts})
and arguments passed to that script.
@item -
Equivalent to @code{--}.
@end table
@cindex login shell
+3 -3
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2023 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Fri Oct 6 16:41:04 EDT 2023
@set LASTCHANGE Wed Nov 1 09:34:00 EDT 2023
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 6 October 2023
@set UPDATED-MONTH October 2023
@set UPDATED 1 November 2023
@set UPDATED-MONTH November 2023
+1
View File
@@ -213,6 +213,7 @@ pretty_print_loop (void)
global_posix_mode = posixly_correct;
last_was_newline = 0;
unset_readahead_token ();
while (EOF_Reached == 0)
{
code = setjmp_nosigs (top_level);
+2 -3
View File
@@ -1,7 +1,6 @@
/* accept - listen for and accept a remote network connection on a given port */
/*
Copyright (C) 2020,2022 Free Software Foundation, Inc.
Copyright (C) 2020,2022,2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -104,7 +103,7 @@ accept_builtin (WORD_LIST *list)
return (EX_USAGE);
}
if (legal_number (list->word->word, &iport) == 0 || iport < 0 || iport > TYPE_MAXIMUM (unsigned short))
if (valid_number (list->word->word, &iport) == 0 || iport < 0 || iport > TYPE_MAXIMUM (unsigned short))
{
builtin_error ("%s: invalid port number", list->word->word);
return (EXECUTION_FAILURE);
+3 -3
View File
@@ -2,7 +2,7 @@
or print them to the standard output */
/*
Copyright (C) 2020,2022 Free Software Foundation, Inc.
Copyright (C) 2020,2022,2023 Free Software Foundation, Inc.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -93,7 +93,7 @@ getlist (char *arg, struct cutpos **opp)
s = BOL;
else
{
if (legal_number (ntok, &num) == 0 || (int)num != num || num <= 0)
if (valid_number (ntok, &num) == 0 || (int)num != num || num <= 0)
{
builtin_error ("%s: invalid list value", ntok);
*opp = poslist;
@@ -108,7 +108,7 @@ getlist (char *arg, struct cutpos **opp)
e = EOL;
else
{
if (legal_number (ltok, &num) == 0 || (int)num != num || num <= 0)
if (valid_number (ltok, &num) == 0 || (int)num != num || num <= 0)
{
builtin_error ("%s: invalid list value", ltok);
*opp = poslist;
+2 -2
View File
@@ -3,7 +3,7 @@
/* See Makefile for compilation details. */
/*
Copyright (C) 2017-2022 Free Software Foundation, Inc.
Copyright (C) 2017-2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -327,7 +327,7 @@ fdflags_builtin (WORD_LIST *list)
opt = EXECUTION_SUCCESS;
for (l = list; l; l = l->next)
{
if (legal_number (l->word->word, &inum) == 0 || inum < 0)
if (valid_number (l->word->word, &inum) == 0 || inum < 0)
{
builtin_error ("%s: invalid file descriptor", l->word->word);
opt = EXECUTION_FAILURE;
+2 -2
View File
@@ -161,7 +161,7 @@ getstat(char *f)
intmax_t lfd;
if (strncmp(f, "/dev/fd/", 8) == 0) {
if ((legal_number(f + 8, &lfd) == 0) || (int)lfd != lfd) {
if ((valid_number(f + 8, &lfd) == 0) || (int)lfd != lfd) {
builtin_error("%s: invalid fd", f + 8);
return ((struct stat *)0);
}
@@ -495,7 +495,7 @@ base_pathname(char *p)
}
int
legal_number (char *string, long result)
valid_number (char *string, long result)
{
int sign;
long value;
+3 -3
View File
@@ -2,7 +2,7 @@
print them to the standard output */
/*
Copyright (C) 2020,2022 Free Software Foundation, Inc.
Copyright (C) 2020,2022,2023 Free Software Foundation, Inc.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -91,7 +91,7 @@ getlist (char *arg, struct cutpos **opp)
s = BOL;
else
{
if (legal_number (ntok, &num) == 0 || (int)num != num || num <= 0)
if (valid_number (ntok, &num) == 0 || (int)num != num || num <= 0)
{
builtin_error ("%s: invalid list value", ntok);
*opp = poslist;
@@ -106,7 +106,7 @@ getlist (char *arg, struct cutpos **opp)
e = EOL;
else
{
if (legal_number (ltok, &num) == 0 || (int)num != num || num <= 0)
if (valid_number (ltok, &num) == 0 || (int)num != num || num <= 0)
{
builtin_error ("%s: invalid list value", ltok);
*opp = poslist;
+3 -3
View File
@@ -4,7 +4,7 @@
Originally contributed by Jason Vas Dias <jason.vas.dias@gmail.com>
Copyright (C) 2018-2022 Free Software Foundation, Inc.
Copyright (C) 2018-2023 Free Software Foundation, Inc.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -69,7 +69,7 @@ setpgid_builtin (WORD_LIST *list)
return (EX_USAGE);
}
if (legal_number (pidstr, &pid_arg) == 0)
if (valid_number (pidstr, &pid_arg) == 0)
{
builtin_error ("%s: pid argument must be numeric", pidstr);
return (EXECUTION_FAILURE);
@@ -81,7 +81,7 @@ setpgid_builtin (WORD_LIST *list)
}
pid = pid_arg;
if (legal_number (pgidstr, &pgid_arg) == 0)
if (valid_number (pgidstr, &pgid_arg) == 0)
{
builtin_error ("%s: pgrp argument must be numeric", pgidstr);
return (EXECUTION_FAILURE);
+1 -1
View File
@@ -87,7 +87,7 @@ getstat (const char *fname, int flags, struct stat *sp)
if (strncmp (fname, "/dev/fd/", 8) == 0)
{
if ((legal_number(fname + 8, &lfd) == 0) || (int)lfd != lfd)
if ((valid_number(fname + 8, &lfd) == 0) || (int)lfd != lfd)
{
errno = EINVAL;
return -1;
+2 -2
View File
@@ -3,7 +3,7 @@
/* See Makefile for compilation details. */
/*
Copyright (C) 1999-2009,2022 Free Software Foundation, Inc.
Copyright (C) 1999-2009,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash.
Bash is free software: you can redistribute it and/or modify
@@ -67,7 +67,7 @@ strftime_builtin (WORD_LIST *list)
if (list && list->word->word)
{
n = legal_number (list->word->word, &i);
n = valid_number (list->word->word, &i);
if (n == 0 || i < 0 || i != (time_t)i)
{
sh_invalidnum (list->word->word);
+2 -2
View File
@@ -2428,7 +2428,7 @@ execute_coproc (COMMAND *command, int pipe_in, int pipe_out, struct fd_bitmap *f
/* expand name without splitting - could make this dependent on a shopt option */
name = expand_string_unsplit_to_string (command->value.Coproc->name, 0);
/* Optional check -- could be relaxed */
if (legal_identifier (name) == 0)
if (valid_identifier (name) == 0)
{
internal_error (_("`%s': not a valid identifier"), name);
free (name);
@@ -3381,7 +3381,7 @@ select_query (WORD_LIST *list, int list_len, char *prompt, int print_menu)
print_menu = 1;
continue;
}
if (legal_number (repl_string, &reply) == 0)
if (valid_number (repl_string, &reply) == 0)
return "";
if (reply < 1 || reply > list_len)
return "";
+1 -1
View File
@@ -355,7 +355,7 @@ expr_skipsubscript (char *vp, char *cp)
if (array_expand_once & already_expanded)
{
*cp = '\0';
isassoc = legal_identifier (vp) && (entry = find_variable (vp)) && assoc_p (entry);
isassoc = valid_identifier (vp) && (entry = find_variable (vp)) && assoc_p (entry);
*cp = '['; /* ] */
}
flags = (isassoc && array_expand_once && already_expanded) ? VA_NOEXPAND : 0;
+1 -1
View File
@@ -214,7 +214,7 @@ extern void print_clock_t (FILE *, clock_t);
/* Declarations for functions defined in lib/sh/dprintf.c */
#if !defined (HAVE_DPRINTF)
extern void dprintf (int, const char *, ...) __attribute__((__format__ (printf, 2, 3));
extern void dprintf (int, const char *, ...) __attribute__((__format__ (printf, 2, 3)));
#endif
/* Declarations for functions defined in lib/sh/fmtulong.c */
+11 -11
View File
@@ -1,6 +1,6 @@
/* general.c -- Stuff that is used by all files. */
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -241,7 +241,7 @@ all_digits (const char *string)
valid number. Stuff the converted number into RESULT if RESULT is
not null. */
int
legal_number (const char *string, intmax_t *result)
valid_number (const char *string, intmax_t *result)
{
intmax_t value;
char *ep;
@@ -277,11 +277,11 @@ legal_number (const char *string, intmax_t *result)
return (0);
}
/* Return 1 if this token is a legal shell `identifier'; that is, it consists
/* Return 1 if this token is a valid shell `identifier'; that is, it consists
solely of letters, digits, and underscores, and does not begin with a
digit. */
int
legal_identifier (const char *name)
valid_identifier (const char *name)
{
register const char *s;
unsigned char c;
@@ -310,9 +310,9 @@ valid_nameref_value (const char *name, int flags)
/* valid identifier */
#if defined (ARRAY_VARS)
if (legal_identifier (name) || (flags != 2 && valid_array_reference (name, 0)))
if (valid_identifier (name) || (flags != 2 && valid_array_reference (name, 0)))
#else
if (legal_identifier (name))
if (valid_identifier (name))
#endif
return 1;
@@ -356,7 +356,7 @@ check_identifier (WORD_DESC *word, int check_word)
internal_error (_("`%s': not a valid identifier"), word->word);
return (0);
}
else if (check_word && (all_digits (word->word) || legal_identifier (word->word) == 0))
else if (check_word && (all_digits (word->word) || valid_identifier (word->word) == 0))
{
internal_error (_("`%s': not a valid identifier"), word->word);
return (0);
@@ -379,7 +379,7 @@ importable_function_name (const char *string, size_t len)
return 0;
if (shellblank (*string) || shellblank(string[len-1]))
return 0;
return (posixly_correct ? legal_identifier (string) : 1);
return (posixly_correct ? valid_identifier (string) : 1);
}
int
@@ -396,7 +396,7 @@ exportable_function_name (const char *string)
essentially all characters except those which must be quoted to the
parser (which disqualifies them from alias expansion anyway) and `/'. */
int
legal_alias_name (const char *string, int flags)
valid_alias_name (const char *string, int flags)
{
register const char *s;
@@ -416,7 +416,7 @@ valid_function_name (const char *name, int flags)
{
if ((flags & 1) && find_reserved_word (name) >= 0)
return 0;
if ((flags & 1) && (all_digits (name) || legal_identifier (name) == 0))
if ((flags & 1) && (all_digits (name) || valid_identifier (name) == 0))
return 0;
/* pass flags & 2 to suppress this check */
if ((flags & 2) == 0 && assignment (name, 0)) /* difference between WORD and ASSIGNMENT_WORD */
@@ -943,7 +943,7 @@ trim_pathname (char *name, int maxlen)
v = get_string_value ("PROMPT_DIRTRIM");
if (v == 0 || *v == 0)
return name;
if (legal_number (v, &nskip) == 0 || nskip <= 0)
if (valid_number (v, &nskip) == 0 || nskip <= 0)
return name;
/* Skip over tilde prefix */
+3 -3
View File
@@ -299,14 +299,14 @@ extern void print_rlimtype (RLIMTYPE, int);
#endif
extern int all_digits (const char *);
extern int legal_number (const char *, intmax_t *);
extern int legal_identifier (const char *);
extern int valid_number (const char *, intmax_t *);
extern int valid_identifier (const char *);
extern int importable_function_name (const char *, size_t);
extern int exportable_function_name (const char *);
extern int check_identifier (WORD_DESC *, int);
extern int valid_nameref_value (const char *, int);
extern int check_selfref (const char *, char *, int);
extern int legal_alias_name (const char *, int);
extern int valid_alias_name (const char *, int);
extern int valid_function_name (const char *, int);
extern int valid_function_word (WORD_DESC *, int);
extern int line_isblank (const char *);
+15 -2
View File
@@ -95,7 +95,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
ufuncs.c casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \
strvis.c strlcpy.c strscpy.c utf8.c random.c gettimeofday.c \
timers.c anonfile.c
timers.c anonfile.c compat.c
# The header files for this library.
HSOURCES =
@@ -110,7 +110,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
fpurge.o zgetline.o mbscmp.o mbsncmp.o uconvert.o ufuncs.o casemod.o \
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o strvis.o \
strscpy.o anonfile.o \
strscpy.o anonfile.o compat.o \
utf8.o random.o gettimeofday.o timers.o wcsnwidth.o ${LIBOBJS}
SUPPORT = Makefile
@@ -150,6 +150,7 @@ anonfile.o: anonfile.c
casemod.o: casemod.c
clktck.o: clktck.c
clock.o: clock.c
compat.o: compat.c
eaccess.o: eaccess.c
dprintf.o: dprintf.c
fmtullong.o: fmtullong.c
@@ -236,6 +237,7 @@ anonfile.o: ${BUILD_DIR}/config.h
casemod.o: ${BUILD_DIR}/config.h
clktck.o: ${BUILD_DIR}/config.h
clock.o: ${BUILD_DIR}/config.h
compat.o: ${BUILD_DIR}/config.h
eaccess.o: ${BUILD_DIR}/config.h
dprintf.o: ${BUILD_DIR}/config.h
fmtullong.o: ${BUILD_DIR}/config.h
@@ -688,3 +690,14 @@ anonfile.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
anonfile.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
anonfile.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
anonfile.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
compat.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
compat.o: ${topdir}/bashtypes.h
compat.o: ${BASHINCDIR}/filecntl.h
compat.o: ${topdir}/shell.h ${topdir}/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
compat.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
compat.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h ${topdir}/conftypes.h
compat.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
compat.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
compat.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
compat.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
+47
View File
@@ -0,0 +1,47 @@
/* compat.c - functions for backwards compatibility with previous versions */
/* Copyright (C) 2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <bashtypes.h>
#include <shell.h>
/* For backwards compatibility with existing loadable builtins. */
int
legal_number (const char *string, intmax_t *result)
{
return (valid_number (string, result));
}
int
legal_identifier (const char *string)
{
return (valid_identifier (string));
}
int
legal_alias_name (const char *string, int flags)
{
return (valid_alias_name (string, flags));
}
+2 -2
View File
@@ -1,6 +1,6 @@
/* eaccess.c - eaccess replacement for the shell, plus other access functions. */
/* Copyright (C) 2006-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 2006-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -94,7 +94,7 @@ sh_stat (const char *path, struct stat *finfo)
intmax_t fd;
int r;
if (legal_number (path + 8, &fd) && fd == (int)fd)
if (valid_number (path + 8, &fd) && fd == (int)fd)
{
r = fstat ((int)fd, finfo);
if (r == 0 || errno != EBADF)
+2 -2
View File
@@ -5,7 +5,7 @@
* chet@ins.CWRU.Edu
*/
/* Copyright (C) 1987-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -117,7 +117,7 @@ _getserv (const char *serv, int proto, unsigned short *pp)
intmax_t l;
unsigned short s;
if (legal_number (serv, &l))
if (valid_number (serv, &l))
{
s = (unsigned short)(l & 0xFFFF);
if (s != l)
+1 -1
View File
@@ -100,7 +100,7 @@ time_to_check_mail (void)
/* Negative number, or non-numbers (such as empty string) cause no
checking to take place. */
if (temp == 0 || legal_number (temp, &seconds) == 0 || seconds < 0)
if (temp == 0 || valid_number (temp, &seconds) == 0 || seconds < 0)
return (0);
now = NOW;
+1 -1
View File
@@ -702,7 +702,7 @@ make_redirection (REDIRECTEE source, enum r_instruction instruction, REDIRECTEE
if (w->word[wlen] == '-') /* Yuck */
{
w->word[wlen] = '\0';
if (all_digits (w->word) && legal_number (w->word, &lfd) && lfd == (int)lfd)
if (all_digits (w->word) && valid_number (w->word, &lfd) && lfd == (int)lfd)
{
dispose_word (w);
temp->instruction = (instruction == r_duplicating_input_word) ? r_move_input : r_move_output;
+4 -4
View File
@@ -5168,7 +5168,7 @@ token_is_ident (char *t, int i)
c = t[i];
t[i] = '\0';
r = legal_identifier (t);
r = valid_identifier (t);
t[i] = c;
return r;
}
@@ -5601,7 +5601,7 @@ got_token:
last_read_token == LESS_AND ||
last_read_token == GREATER_AND))
{
if (legal_number (token, &lvalue) && (int)lvalue == lvalue)
if (valid_number (token, &lvalue) && (int)lvalue == lvalue)
{
yylval.number = lvalue;
return (NUMBER);
@@ -5692,9 +5692,9 @@ got_token:
/* can use token; already copied to the_word */
token[token_index-1] = '\0';
#if defined (ARRAY_VARS)
if (legal_identifier (token+1) || valid_array_reference (token+1, 0))
if (valid_identifier (token+1) || valid_array_reference (token+1, 0))
#else
if (legal_identifier (token+1))
if (valid_identifier (token+1))
#endif
{
strcpy (the_word->word, token+1);
+3 -3
View File
@@ -598,7 +598,7 @@ redir_special_open (int spec, char *filename, int flags, int mode, enum r_instru
{
#if !defined (HAVE_DEV_FD)
case RF_DEVFD:
if (all_digits (filename+8) && legal_number (filename+8, &lfd) && lfd == (int)lfd)
if (all_digits (filename+8) && valid_number (filename+8, &lfd) && lfd == (int)lfd)
{
fd = lfd;
fd = fcntl (fd, F_DUPFD, SHELL_FD_BASE);
@@ -800,7 +800,7 @@ do_redirection_internal (REDIRECT *redirect, int flags, char **fnp)
else if (all_digits (redirectee_word))
{
sd = redirect->redirector;
if (legal_number (redirectee_word, &lfd) && (int)lfd == lfd)
if (valid_number (redirectee_word, &lfd) && (int)lfd == lfd)
rd.dest = lfd;
else
rd.dest = -1; /* XXX */
@@ -1459,7 +1459,7 @@ redir_varvalue (REDIRECT *redir)
if (val == 0 || *val == 0)
return -1;
if (legal_number (val, &vmax) == 0)
if (valid_number (val, &vmax) == 0)
return -1;
i = vmax; /* integer truncation */
+14 -8
View File
@@ -7453,7 +7453,7 @@ valid_brace_expansion_word (const char *name, int var_is_special)
else if (valid_array_reference (name, 0))
return 1;
#endif /* ARRAY_VARS */
else if (legal_identifier (name))
else if (valid_identifier (name))
return 1;
else
return 0;
@@ -7547,7 +7547,7 @@ parameter_brace_expand_word (char *name, int var_is_special, int quoted, int pfl
#endif
/* Handle multiple digit arguments, as in ${11}. */
if (legal_number (name, &arg_index))
if (valid_number (name, &arg_index))
{
tt = get_dollar_var_value (arg_index);
if (tt)
@@ -7685,7 +7685,7 @@ expand_arrayref:
else
#endif
/* y=2 ; typeset -n x=y; echo ${x} is not the same as echo ${2} in ksh */
if (temp && *temp && legal_identifier (temp) == 0)
if (temp && *temp && valid_identifier (temp) == 0)
{
set_exit_status (EXECUTION_FAILURE);
report_error (_("%s: invalid variable name for name reference"), temp);
@@ -7779,7 +7779,7 @@ parameter_brace_expand_indir (char *name, int var_is_special, int quoted, int pf
is ok. Indirect references to array references, as explained above, are
ok (currently). Only references to unset variables are errors at this
point. */
if (legal_identifier (name) && v == 0)
if (valid_identifier (name) && v == 0)
{
report_error (_("%s: invalid indirect expansion"), name);
w = alloc_word_desc ();
@@ -7979,7 +7979,7 @@ parameter_brace_expand_rhs (char *name, char *value,
dispose_word (w);
return &expand_wdesc_error;
}
if (legal_identifier (vname) == 0)
if (valid_identifier (vname) == 0)
{
report_error (_("%s: invalid variable name"), vname);
free (vname);
@@ -8118,7 +8118,7 @@ valid_length_expression (const char *name)
#if defined (ARRAY_VARS)
valid_array_reference (name + 1, 0) || /* ${#a[7]} */
#endif
legal_identifier (name + 1)); /* ${#PS1} */
valid_identifier (name + 1)); /* ${#PS1} */
}
/* Handle the parameter brace expansion that requires us to return the
@@ -8169,7 +8169,7 @@ parameter_brace_expand_length (char *name)
else if (valid_array_reference (name + 1, 0))
number = array_length_reference (name + 1);
#endif /* ARRAY_VARS */
else if (legal_number (name + 1, &arg_index)) /* ${#1} */
else if (valid_number (name + 1, &arg_index)) /* ${#1} */
{
t = get_dollar_var_value (arg_index);
if (t == 0 && unbound_vars_is_error)
@@ -10851,7 +10851,7 @@ comsub:
else
#endif
/* y=2 ; typeset -n x=y; echo $x is not the same as echo $2 in ksh */
if (temp && *temp && legal_identifier (temp) == 0)
if (temp && *temp && valid_identifier (temp) == 0)
{
set_exit_status (EXECUTION_FAILURE);
report_error (_("%s: invalid variable name for name reference"), temp);
@@ -12534,6 +12534,12 @@ brace_expand_word_list (WORD_LIST *tlist, int eflags)
if (mbschr (tlist->word->word, LBRACE))
{
expansions = brace_expand (tlist->word->word);
if (expansions == 0)
{
expansions = strvec_create (2);
expansions[0] = savestring (tlist->word->word);
expansions[1] = NULL;
}
for (eindex = 0; temp_string = expansions[eindex]; eindex++)
{
+5 -5
View File
@@ -351,9 +351,9 @@ arithcomp (char *s, char *t, int op, int flags)
}
else
{
if (legal_number (s, &l) == 0)
if (valid_number (s, &l) == 0)
integer_expected_error (s);
if (legal_number (t, &r) == 0)
if (valid_number (t, &r) == 0)
integer_expected_error (t);
}
@@ -489,7 +489,7 @@ unary_operator (void)
advance (0);
if (pos < argc)
{
if (legal_number (argv[pos], &r))
if (valid_number (argv[pos], &r))
{
advance (0);
return (unary_test (op, argv[pos - 1], 0));
@@ -612,7 +612,7 @@ unary_test (char *op, char *arg, int flags)
#endif
case 't': /* File fd is a terminal? */
if (legal_number (arg, &r) == 0)
if (valid_number (arg, &r) == 0)
integer_expected_error (arg);
return ((r == (int)r) && isatty ((int)r));
@@ -650,7 +650,7 @@ unary_test (char *op, char *arg, int flags)
flush_eltstate (&es);
return ret;
}
else if (legal_number (arg, &r)) /* -v n == is $n set? */
else if (valid_number (arg, &r)) /* -v n == is $n set? */
return ((r >= 0 && r <= number_of_args()) ? TRUE : FALSE);
v = find_variable (arg);
if (v && invisible_p (v) == 0 && array_p (v))
+4 -1
View File
@@ -64,5 +64,8 @@ unset -v VAR
# out of range inline precisions
printf "%.${TOOBIG}s\n" XY
# can't test %s, too many varying implementations
#printf "%.${TOOBIG}s\n" XY
printf -v VAR "%.${TOOBIG}s\n" XY
echo $VAR
printf "%.${TOOBIG}Q\n" XY
+3 -3
View File
@@ -238,20 +238,20 @@ decode_signal (const char *string, int flags)
intmax_t sig;
char *name;
if (legal_number (string, &sig))
if (valid_number (string, &sig))
return ((sig >= 0 && sig < NSIG) ? (int)sig : NO_SIG);
#if defined (SIGRTMIN) && defined (SIGRTMAX)
if (STREQN (string, "SIGRTMIN+", 9) || ((flags & DSIG_NOCASE) && strncasecmp (string, "SIGRTMIN+", 9) == 0))
{
if (legal_number (string+9, &sig) && sig >= 0 && sig <= SIGRTMAX - SIGRTMIN)
if (valid_number (string+9, &sig) && sig >= 0 && sig <= SIGRTMAX - SIGRTMIN)
return (SIGRTMIN + sig);
else
return NO_SIG;
}
else if (STREQN (string, "RTMIN+", 6) || ((flags & DSIG_NOCASE) && strncasecmp (string, "RTMIN+", 6) == 0))
{
if (legal_number (string+6, &sig) && sig >= 0 && sig <= SIGRTMAX - SIGRTMIN)
if (valid_number (string+6, &sig) && sig >= 0 && sig <= SIGRTMAX - SIGRTMIN)
return (SIGRTMIN + sig);
else
return NO_SIG;
+16 -16
View File
@@ -419,7 +419,7 @@ initialize_shell_variables (char **env, int privmode)
/* Don't import function names that are invalid identifiers from the
environment in posix mode, though we still allow them to be defined as
shell variables. */
if (absolute_program (tname) == 0 && (posixly_correct == 0 || legal_identifier (tname)))
if (absolute_program (tname) == 0 && (posixly_correct == 0 || valid_identifier (tname)))
parse_and_execute (temp_string, tname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
else
free (temp_string); /* parse_and_execute does this */
@@ -514,7 +514,7 @@ initialize_shell_variables (char **env, int privmode)
if (temp_var)
VUNSETATTR (temp_var, att_readonly);
}
if (legal_identifier (name))
if (valid_identifier (name))
{
temp_var = bind_variable (name, string, 0);
if (temp_var)
@@ -859,7 +859,7 @@ adjust_shell_level (int change)
SHELL_VAR *temp_var;
old_SHLVL = get_string_value ("SHLVL");
if (old_SHLVL == 0 || *old_SHLVL == '\0' || legal_number (old_SHLVL, &old_level) == 0)
if (old_SHLVL == 0 || *old_SHLVL == '\0' || valid_number (old_SHLVL, &old_level) == 0)
old_level = 0;
shell_level = old_level + change;
@@ -1333,7 +1333,7 @@ assign_seconds (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
if (integer_p (self))
nval = evalexp (value, 0, &expok);
else
expok = legal_number (value, &nval);
expok = valid_number (value, &nval);
seconds_value_assigned = expok ? nval : 0;
gettimeofday (&shellstart, NULL);
shell_start_time = shellstart.tv_sec;
@@ -1359,7 +1359,7 @@ init_seconds_var (void)
v = find_variable ("SECONDS");
if (v)
{
if (legal_number (value_cell(v), &seconds_value_assigned) == 0)
if (valid_number (value_cell(v), &seconds_value_assigned) == 0)
seconds_value_assigned = 0;
}
INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds);
@@ -1405,7 +1405,7 @@ assign_random (SHELL_VAR *self, char *value, arrayind_t unused, char *key)
if (integer_p (self))
seedval = evalexp (value, 0, &expok);
else
expok = legal_number (value, &seedval);
expok = valid_number (value, &seedval);
if (expok == 0)
return (self);
sbrand (seedval);
@@ -1457,7 +1457,7 @@ assign_lineno (SHELL_VAR *var, char *value, arrayind_t unused, char *key)
{
intmax_t new_value;
if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
if (value == 0 || *value == '\0' || valid_number (value, &new_value) == 0)
new_value = 0;
line_number = line_number_base = new_value;
return (set_int_value (var, line_number, integer_p (var) != 0));
@@ -1478,7 +1478,7 @@ assign_subshell (SHELL_VAR *var, char *value, arrayind_t unused, char *key)
{
intmax_t new_value;
if (value == 0 || *value == '\0' || legal_number (value, &new_value) == 0)
if (value == 0 || *value == '\0' || valid_number (value, &new_value) == 0)
new_value = 0;
subshell_level = new_value;
return var;
@@ -1790,7 +1790,7 @@ get_aliasvar (SHELL_VAR *self)
static SHELL_VAR *
assign_aliasvar (SHELL_VAR *self, char *value, arrayind_t ind, char *key)
{
if (legal_alias_name (key, 0) == 0)
if (valid_alias_name (key, 0) == 0)
{
report_error (_("`%s': invalid alias name"), key);
return (self);
@@ -2204,7 +2204,7 @@ find_variable_nameref_for_create (const char *name, int flags)
}
if (var && nameref_p (var))
{
if (legal_identifier (nameref_cell (var)) == 0)
if (valid_identifier (nameref_cell (var)) == 0)
{
sh_invalidid (nameref_cell (var) ? nameref_cell (var) : "");
return ((SHELL_VAR *)INVALID_NAMEREF_VALUE);
@@ -3390,7 +3390,7 @@ bind_int_variable (const char *lhs, const char *rhs, int flags)
avflags = convert_assign_flags_to_arrayval_flags (flags);
v = array_variable_part (lhs, avflags, (char **)0, (int *)0);
}
else if (legal_identifier (lhs) == 0)
else if (valid_identifier (lhs) == 0)
{
sh_invalidid (lhs);
return ((SHELL_VAR *)NULL);
@@ -3547,7 +3547,7 @@ assign_in_env (const WORD_DESC *word, int flags)
aflags |= ASS_APPEND;
}
if (legal_identifier (name) == 0)
if (valid_identifier (name) == 0)
{
sh_invalidid (name);
free (name);
@@ -5628,7 +5628,7 @@ pop_args (void)
GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a);
ce = array_unshift_element (bash_argc_a);
if (ce == 0 || legal_number (element_value (ce), &i) == 0)
if (ce == 0 || valid_number (element_value (ce), &i) == 0)
i = 0;
for ( ; i > 0; i--)
@@ -5858,7 +5858,7 @@ sv_funcnest (const char *name)
v = find_variable (name);
if (v == 0)
funcnest_max = 0;
else if (legal_number (value_cell (v), &num) == 0)
else if (valid_number (value_cell (v), &num) == 0)
funcnest_max = 0;
else
funcnest_max = num;
@@ -5938,7 +5938,7 @@ sv_winsize (const char *name)
rl_reset_screen_size ();
else
{
if (legal_number (value_cell (v), &xd) == 0)
if (valid_number (value_cell (v), &xd) == 0)
return;
winsize_assignment = 1;
d = xd; /* truncate */
@@ -5980,7 +5980,7 @@ sv_histsize (const char *name)
if (temp && *temp)
{
if (legal_number (temp, &num))
if (valid_number (temp, &num))
{
hmax = num;
if (hmax < 0 && name[4] == 'S')