doc/bash.1,doc/bashref.texi
- BASH_REMATCH: update [[ documentation to note that BASH_REMATCH can
be a local variable
+
+ 3/20
+ ----
+subst.c
+ - word_list_quote_removal,word_list_split: fix initial setting of E
+ on first word split (RESULT == 0). If TRESULT expands to multiple
+ words, all but the first word were dropped because we didn't set
+ E to the end of the TRESULT list
+
+ 3/30
+ ----
+builtins/complete.def
+ - print_cmd_name: prefix command names starting with `-' (however
+ unlikely) with `--'
+ Report from Étienne Barrié <etienne.barrie@gmail.com>
+ - print_cmd_name: use ansic_quote() to quote the command name if
+ necessary
+
+builtins/type.def,builtins/complete.def,builtins/alias.def,builtins/type.def
+print_cmd.c
+ - check for possible $'...' quoting and use it if appropriate instead
+ of just calling sh_single_quote()
l = REVERSE_LIST(list, WORD_LIST *);
- result = l ? string_list_internal (l, sep) : savestring ("");
+ result = l ? string_list_internal (l, sep, 0) : savestring ("");
dispose_words (l);
return result;
{
char *value;
- value = sh_single_quote (alias->value);
+ if (ansic_shouldquote (alias->value))
+ value = ansic_quote (alias->value, 0, (int *)0);
+ else
+ value = sh_single_quote (alias->value);
if (flags & AL_REUSABLE)
printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");
printf ("%s=%s\n", alias->name, value);
if (arg)
{
- x = quote ? sh_single_quote (arg) : (char *)arg;
+ if (quote)
+ {
+ if (ansic_shouldquote (arg))
+ x = ansic_quote (arg, 0, (int *)0);
+ else
+ x = sh_single_quote (arg);
+ }
+ else
+ x = (char *)arg;
printf ("%s %s ", flag, x);
if (x != arg)
free (x);
print_cmd_name (const char *cmd)
{
char *x;
+ char *fmt;
+ fmt = (*cmd == '-') ? "-- %s" : "%s";
+
if (STREQ (cmd, DEFAULTCMD))
printf ("-D");
else if (STREQ (cmd, EMPTYCMD))
printf ("-I");
else if (*cmd == 0) /* XXX - can this happen? */
printf ("''");
+ else if (ansic_shouldquote (cmd))
+ {
+ x = ansic_quote (cmd, 0, (int *)0);
+ printf (fmt, x);
+ free (x);
+ }
else if (sh_contains_shell_metas (cmd))
{
x = sh_single_quote (cmd);
- printf ("%s", x);
+ printf (fmt, x);
free (x);
}
else
- printf ("%s", cmd);
+ printf (fmt, cmd);
}
static int
}
else if (signal_is_hard_ignored (i))
t = (char *)NULL;
- else
- t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p);
+ else if (p == (char *)IGNORE_SIG)
+ t = (char *)NULL;
+ else if (ansic_shouldquote (p))
+ t = ansic_quote (p, 0, (int *)0);
+ else
+ t = sh_single_quote (p);
sn = signal_name (i);
/* Make sure that signals whose names are unknown (for whatever reason)
printf (_("%s is aliased to `%s'\n"), command, alias->value);
else if (dflags & CDESC_REUSABLE)
{
- x = sh_single_quote (alias->value);
+ if (ansic_shouldquote (alias->value))
+ x = ansic_quote (alias->value, 0, (int *)0);
+ else
+ x = sh_single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
explicitly declares an array. There is no maximum limit on the size of
an array, nor any requirement that members be indexed or assigned
contiguously. Indexed arrays are referenced using arithmetic
-expressions that must expand to an integer (*note Shell Arithmetic::))
+expressions that must expand to an integer (*note Shell Arithmetic::)
and are zero-based; associative arrays use arbitrary strings. Unless
otherwise noted, indexed array indices must be non-negative integers.
Node: Shell Arithmetic\7f316505
Node: Aliases\7f319832
Node: Arrays\7f322966
-Node: The Directory Stack\7f330669
-Node: Directory Stack Builtins\7f331466
-Node: Controlling the Prompt\7f335911
-Node: The Restricted Shell\7f338795
-Node: Bash POSIX Mode\7f341888
-Node: Shell Compatibility Mode\7f361704
-Node: Job Control\7f370711
-Node: Job Control Basics\7f371168
-Node: Job Control Builtins\7f377536
-Node: Job Control Variables\7f384324
-Node: Command Line Editing\7f385555
-Node: Introduction and Notation\7f387258
-Node: Readline Interaction\7f389610
-Node: Readline Bare Essentials\7f390798
-Node: Readline Movement Commands\7f392606
-Node: Readline Killing Commands\7f393602
-Node: Readline Arguments\7f395625
-Node: Searching\7f396715
-Node: Readline Init File\7f398958
-Node: Readline Init File Syntax\7f400261
-Node: Conditional Init Constructs\7f427212
-Node: Sample Init File\7f431597
-Node: Bindable Readline Commands\7f434717
-Node: Commands For Moving\7f436255
-Node: Commands For History\7f438719
-Node: Commands For Text\7f444110
-Node: Commands For Killing\7f448235
-Node: Numeric Arguments\7f451023
-Node: Commands For Completion\7f452175
-Node: Keyboard Macros\7f457871
-Node: Miscellaneous Commands\7f458572
-Node: Readline vi Mode\7f466115
-Node: Programmable Completion\7f467092
-Node: Programmable Completion Builtins\7f476828
-Node: A Programmable Completion Example\7f488565
-Node: Using History Interactively\7f493910
-Node: Bash History Facilities\7f494591
-Node: Bash History Builtins\7f498326
-Node: History Interaction\7f505921
-Node: Event Designators\7f510871
-Node: Word Designators\7f512449
-Node: Modifiers\7f514841
-Node: Installing Bash\7f516778
-Node: Basic Installation\7f517894
-Node: Compilers and Options\7f521770
-Node: Compiling For Multiple Architectures\7f522520
-Node: Installation Names\7f524273
-Node: Specifying the System Type\7f526507
-Node: Sharing Defaults\7f527253
-Node: Operation Controls\7f527967
-Node: Optional Features\7f528986
-Node: Reporting Bugs\7f541709
-Node: Major Differences From The Bourne Shell\7f543066
-Node: GNU Free Documentation License\7f564493
-Node: Indexes\7f589670
-Node: Builtin Index\7f590121
-Node: Reserved Word Index\7f597219
-Node: Variable Index\7f599664
-Node: Function Index\7f617077
-Node: Concept Index\7f631210
+Node: The Directory Stack\7f330668
+Node: Directory Stack Builtins\7f331465
+Node: Controlling the Prompt\7f335910
+Node: The Restricted Shell\7f338794
+Node: Bash POSIX Mode\7f341887
+Node: Shell Compatibility Mode\7f361703
+Node: Job Control\7f370710
+Node: Job Control Basics\7f371167
+Node: Job Control Builtins\7f377535
+Node: Job Control Variables\7f384323
+Node: Command Line Editing\7f385554
+Node: Introduction and Notation\7f387257
+Node: Readline Interaction\7f389609
+Node: Readline Bare Essentials\7f390797
+Node: Readline Movement Commands\7f392605
+Node: Readline Killing Commands\7f393601
+Node: Readline Arguments\7f395624
+Node: Searching\7f396714
+Node: Readline Init File\7f398957
+Node: Readline Init File Syntax\7f400260
+Node: Conditional Init Constructs\7f427211
+Node: Sample Init File\7f431596
+Node: Bindable Readline Commands\7f434716
+Node: Commands For Moving\7f436254
+Node: Commands For History\7f438718
+Node: Commands For Text\7f444109
+Node: Commands For Killing\7f448234
+Node: Numeric Arguments\7f451022
+Node: Commands For Completion\7f452174
+Node: Keyboard Macros\7f457870
+Node: Miscellaneous Commands\7f458571
+Node: Readline vi Mode\7f466114
+Node: Programmable Completion\7f467091
+Node: Programmable Completion Builtins\7f476827
+Node: A Programmable Completion Example\7f488564
+Node: Using History Interactively\7f493909
+Node: Bash History Facilities\7f494590
+Node: Bash History Builtins\7f498325
+Node: History Interaction\7f505920
+Node: Event Designators\7f510870
+Node: Word Designators\7f512448
+Node: Modifiers\7f514840
+Node: Installing Bash\7f516777
+Node: Basic Installation\7f517893
+Node: Compilers and Options\7f521769
+Node: Compiling For Multiple Architectures\7f522519
+Node: Installation Names\7f524272
+Node: Specifying the System Type\7f526506
+Node: Sharing Defaults\7f527252
+Node: Operation Controls\7f527966
+Node: Optional Features\7f528985
+Node: Reporting Bugs\7f541708
+Node: Major Differences From The Bourne Shell\7f543065
+Node: GNU Free Documentation License\7f564492
+Node: Indexes\7f589669
+Node: Builtin Index\7f590120
+Node: Reserved Word Index\7f597218
+Node: Variable Index\7f599663
+Node: Function Index\7f617076
+Node: Concept Index\7f631209
\1f
End Tag Table
explicitly declares an array. There is no maximum limit on the size of
an array, nor any requirement that members be indexed or assigned
contiguously. Indexed arrays are referenced using arithmetic
-expressions that must expand to an integer (*note Shell Arithmetic::))
+expressions that must expand to an integer (*note Shell Arithmetic::)
and are zero-based; associative arrays use arbitrary strings. Unless
otherwise noted, indexed array indices must be non-negative integers.
Node: Shell Arithmetic\7f316715
Node: Aliases\7f320045
Node: Arrays\7f323182
-Node: The Directory Stack\7f330888
-Node: Directory Stack Builtins\7f331688
-Node: Controlling the Prompt\7f336136
-Node: The Restricted Shell\7f339023
-Node: Bash POSIX Mode\7f342119
-Node: Shell Compatibility Mode\7f361938
-Node: Job Control\7f370948
-Node: Job Control Basics\7f371408
-Node: Job Control Builtins\7f377779
-Node: Job Control Variables\7f384570
-Node: Command Line Editing\7f385804
-Node: Introduction and Notation\7f387510
-Node: Readline Interaction\7f389865
-Node: Readline Bare Essentials\7f391056
-Node: Readline Movement Commands\7f392867
-Node: Readline Killing Commands\7f393866
-Node: Readline Arguments\7f395892
-Node: Searching\7f396985
-Node: Readline Init File\7f399231
-Node: Readline Init File Syntax\7f400537
-Node: Conditional Init Constructs\7f427491
-Node: Sample Init File\7f431879
-Node: Bindable Readline Commands\7f435002
-Node: Commands For Moving\7f436543
-Node: Commands For History\7f439010
-Node: Commands For Text\7f444404
-Node: Commands For Killing\7f448532
-Node: Numeric Arguments\7f451323
-Node: Commands For Completion\7f452478
-Node: Keyboard Macros\7f458177
-Node: Miscellaneous Commands\7f458881
-Node: Readline vi Mode\7f466427
-Node: Programmable Completion\7f467407
-Node: Programmable Completion Builtins\7f477146
-Node: A Programmable Completion Example\7f488886
-Node: Using History Interactively\7f494234
-Node: Bash History Facilities\7f494918
-Node: Bash History Builtins\7f498656
-Node: History Interaction\7f506254
-Node: Event Designators\7f511207
-Node: Word Designators\7f512788
-Node: Modifiers\7f515183
-Node: Installing Bash\7f517123
-Node: Basic Installation\7f518242
-Node: Compilers and Options\7f522121
-Node: Compiling For Multiple Architectures\7f522874
-Node: Installation Names\7f524630
-Node: Specifying the System Type\7f526867
-Node: Sharing Defaults\7f527616
-Node: Operation Controls\7f528333
-Node: Optional Features\7f529355
-Node: Reporting Bugs\7f542081
-Node: Major Differences From The Bourne Shell\7f543441
-Node: GNU Free Documentation License\7f564871
-Node: Indexes\7f590051
-Node: Builtin Index\7f590505
-Node: Reserved Word Index\7f597606
-Node: Variable Index\7f600054
-Node: Function Index\7f617470
-Node: Concept Index\7f631606
+Node: The Directory Stack\7f330887
+Node: Directory Stack Builtins\7f331687
+Node: Controlling the Prompt\7f336135
+Node: The Restricted Shell\7f339022
+Node: Bash POSIX Mode\7f342118
+Node: Shell Compatibility Mode\7f361937
+Node: Job Control\7f370947
+Node: Job Control Basics\7f371407
+Node: Job Control Builtins\7f377778
+Node: Job Control Variables\7f384569
+Node: Command Line Editing\7f385803
+Node: Introduction and Notation\7f387509
+Node: Readline Interaction\7f389864
+Node: Readline Bare Essentials\7f391055
+Node: Readline Movement Commands\7f392866
+Node: Readline Killing Commands\7f393865
+Node: Readline Arguments\7f395891
+Node: Searching\7f396984
+Node: Readline Init File\7f399230
+Node: Readline Init File Syntax\7f400536
+Node: Conditional Init Constructs\7f427490
+Node: Sample Init File\7f431878
+Node: Bindable Readline Commands\7f435001
+Node: Commands For Moving\7f436542
+Node: Commands For History\7f439009
+Node: Commands For Text\7f444403
+Node: Commands For Killing\7f448531
+Node: Numeric Arguments\7f451322
+Node: Commands For Completion\7f452477
+Node: Keyboard Macros\7f458176
+Node: Miscellaneous Commands\7f458880
+Node: Readline vi Mode\7f466426
+Node: Programmable Completion\7f467406
+Node: Programmable Completion Builtins\7f477145
+Node: A Programmable Completion Example\7f488885
+Node: Using History Interactively\7f494233
+Node: Bash History Facilities\7f494917
+Node: Bash History Builtins\7f498655
+Node: History Interaction\7f506253
+Node: Event Designators\7f511206
+Node: Word Designators\7f512787
+Node: Modifiers\7f515182
+Node: Installing Bash\7f517122
+Node: Basic Installation\7f518241
+Node: Compilers and Options\7f522120
+Node: Compiling For Multiple Architectures\7f522873
+Node: Installation Names\7f524629
+Node: Specifying the System Type\7f526866
+Node: Sharing Defaults\7f527615
+Node: Operation Controls\7f528332
+Node: Optional Features\7f529354
+Node: Reporting Bugs\7f542080
+Node: Major Differences From The Bourne Shell\7f543440
+Node: GNU Free Documentation License\7f564870
+Node: Indexes\7f590050
+Node: Builtin Index\7f590504
+Node: Reserved Word Index\7f597605
+Node: Variable Index\7f600053
+Node: Function Index\7f617469
+Node: Concept Index\7f631605
\1f
End Tag Table
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously.
Indexed arrays are referenced using arithmetic expressions
-that must expand to an integer (@pxref{Shell Arithmetic}))
+that must expand to an integer (@pxref{Shell Arithmetic})
and are zero-based;
associative arrays use arbitrary strings.
Unless otherwise noted, indexed array indices must be non-negative integers.
break;
case ARITH_FOR_EXPRS:
if (yylval.word_list)
- t = string_list_internal (yylval.word_list, " ; ");
+ t = string_list_internal (yylval.word_list, " ; ", 0);
break;
case COND_CMD:
t = (char *)NULL; /* punt */
/* If the here document delimiter is quoted, single-quote it. */
if (redirect->redirectee.filename->flags & W_QUOTED)
{
- x = sh_single_quote (redirect->here_doc_eof);
+ if (ansic_shouldquote (redirect->here_doc_eof))
+ x = ansic_quote (redirect->here_doc_eof, 0, (int *)0);
+ else
+ x = sh_single_quote (redirect->here_doc_eof);
cprintf ("<<%s%s", kill_leading ? "-" : "", x);
free (x);
}
/* Return a single string of all the words in LIST. SEP is the separator
to put between individual elements of LIST in the output string. */
char *
-string_list_internal (WORD_LIST *list, char *sep)
+string_list_internal (WORD_LIST *list, char *sep, int flags)
{
register WORD_LIST *t;
char *result, *r;
char *
string_list (WORD_LIST *list)
{
- return (string_list_internal (list, " "));
+ return (string_list_internal (list, " ", 0));
}
/* An external interface that can be used by the rest of the shell to
sep[1] = '\0';
#endif
- ret = string_list_internal (list, sep);
+ ret = string_list_internal (list, sep, 0);
#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__)
free (sep);
#endif
? quote_list (list)
: list_quote_escapes (list);
- ret = string_list_internal (tlist, sep);
+ ret = string_list_internal (tlist, sep, 0);
#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__)
free (sep);
#endif
string_list_dollar_star for "$@" otherwise. */
if (l->next && ifs_is_null)
{
- temp = string_list_internal (l, " ");
+ temp = string_list_internal (l, " ", 0);
w->flags |= W_SPLITSPACE;
}
else if (l_hasdollat || l->next)
if (result == 0)
result = e = tresult;
else
- {
- e->next = tresult;
- while (e->next)
- e = e->next;
- }
+ e->next = tresult;
+
+ while (e && e->next)
+ e = e->next;
}
return (result);
}
if (result == 0)
result = e = tresult;
else
- {
- e->next = tresult;
- while (e->next)
- e = e->next;
- }
+ e->next = tresult;
+
+ while (e && e->next)
+ e = e->next;
}
return (result);
}
/* Return a single string of all the words present in LIST, separating
each word with SEP. */
-extern char *string_list_internal (WORD_LIST *, char *);
+extern char *string_list_internal (WORD_LIST *, char *, int);
/* Return a single string of all the words present in LIST, separating
each word with a space. */