mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-29 16:39:53 +02:00
commit bash-20110909 snapshot
This commit is contained in:
@@ -12136,3 +12136,46 @@ lib/sh/strtrans.c
|
||||
code converts them to wide characters and uses iswprint to check
|
||||
valid wide chars. From a patch sent by Roman Rakus
|
||||
<rrakus@redhat.com>
|
||||
|
||||
9/7
|
||||
---
|
||||
lib/sh/shquote.c
|
||||
- sh_backslash_quote: change to be table-driven so we can use a
|
||||
different table if we want to
|
||||
- sh_backslash_quote: takes a second char table[256] argument;
|
||||
|
||||
externs.h
|
||||
- sh_backslash_quote: add second argument to function prototype
|
||||
|
||||
bashline.c,braces.c,parse.y,builtins/printf.def
|
||||
- change callers of sh_backslash_quote to add second argument
|
||||
|
||||
bashline.c
|
||||
- filename_bstab: table of characters to pass to sh_backslash_quote;
|
||||
characters with value 1 will be backslash-quoted
|
||||
- set_filename_bstab: turn on characters in filename backslash-quote
|
||||
table according to passed string argument
|
||||
- call set_filename_bstab every time rl_filename_quote_characters is
|
||||
assigned a value
|
||||
- bash_quote_filename: call sh_backslash_quote with filename_bstab
|
||||
as second argument. This allows other characters in filenames to
|
||||
be quoted without quoting, for instance, a dollar sign in a shell
|
||||
variable reference
|
||||
|
||||
9/8
|
||||
---
|
||||
bashline.c
|
||||
- complete_fullquote: new variable, controls table passed to
|
||||
sh_backslash_quote. If non-zero (the default), the standard set
|
||||
of shell metacharacters -- as in bash versions up to and including
|
||||
bash-4.2 -- gets backslash-quoted by the completion code. If zero,
|
||||
sh_backslash_quote gets the table with the characters in the
|
||||
variable reference removed, which means they are removed from the
|
||||
set of characters to be quoted in filenames
|
||||
|
||||
9/10
|
||||
----
|
||||
bashline.c
|
||||
- bash_filename_stat_hook: new function, designed to expand variable
|
||||
references in filenames before readline passes them to stat(2)
|
||||
to determine whether or not they are a directory
|
||||
|
||||
@@ -12121,3 +12121,54 @@ support/shobj-conf
|
||||
- handle compilation on Lion (Mac OS X 10.7/darwin11) with changes
|
||||
to darwin stanzas. Fixes readline bug reported by Vincent
|
||||
Sheffer <vince.sheffer@apisphere.com>
|
||||
|
||||
lib/sh/strtrans.c
|
||||
- ansic_wshouldquote: check a string with multi-byte characters for
|
||||
characters that needs to be backslash-octal escaped for $'...'
|
||||
- ansic_shouldquote: if is_basic fails for one character, let
|
||||
ansic_wshouldquote examine the rest of the string and return what
|
||||
it returns. From a patch sent by Roman Rakus <rrakus@redhat.com>
|
||||
|
||||
8/30
|
||||
----
|
||||
lib/sh/strtrans.c
|
||||
- ansic_quote: changes to quote (or not) multibyte characters. New
|
||||
code converts them to wide characters and uses iswprint to check
|
||||
valid wide chars. From a patch sent by Roman Rakus
|
||||
<rrakus@redhat.com>
|
||||
|
||||
9/7
|
||||
---
|
||||
lib/sh/shquote.c
|
||||
- sh_backslash_quote: change to be table-driven so we can use a
|
||||
different table if we want to
|
||||
- sh_backslash_quote: takes a second char table[256] argument;
|
||||
|
||||
externs.h
|
||||
- sh_backslash_quote: add second argument to function prototype
|
||||
|
||||
bashline.c,braces.c,parse.y,builtins/printf.def
|
||||
- change callers of sh_backslash_quote to add second argument
|
||||
|
||||
bashline.c
|
||||
- filename_bstab: table of characters to pass to sh_backslash_quote;
|
||||
characters with value 1 will be backslash-quoted
|
||||
- set_filename_bstab: turn on characters in filename backslash-quote
|
||||
table according to passed string argument
|
||||
- call set_filename_bstab every time rl_filename_quote_characters is
|
||||
assigned a value
|
||||
- bash_quote_filename: call sh_backslash_quote with filename_bstab
|
||||
as second argument. This allows other characters in filenames to
|
||||
be quoted without quoting, for instance, a dollar sign in a shell
|
||||
variable reference
|
||||
|
||||
9/8
|
||||
---
|
||||
bashline.c
|
||||
- complete_fullquote: new variable, controls table passed to
|
||||
sh_backslash_quote. If non-zero (the default), the standard set
|
||||
of shell metacharacters -- as in bash versions up to and including
|
||||
bash-4.2 -- gets backslash-quoted by the completion code. If zero,
|
||||
sh_backslash_quote gets the table with the characters in the
|
||||
variable reference removed, which means they are removed from the
|
||||
set of characters to be quoted in filenames
|
||||
|
||||
+81
-2
@@ -116,13 +116,15 @@ static int bash_backward_kill_shellword __P((int, int));
|
||||
static char *restore_tilde __P((char *, char *));
|
||||
|
||||
static char *bash_filename_rewrite_hook __P((char *, int));
|
||||
|
||||
static void bash_directory_expansion __P((char **));
|
||||
static int bash_filename_stat_hook __P((char **));
|
||||
static int bash_directory_completion_hook __P((char **));
|
||||
static int filename_completion_ignore __P((char **));
|
||||
static int bash_push_line __P((void));
|
||||
|
||||
static rl_icppfunc_t *save_directory_hook __P((void));
|
||||
static void reset_directory_hook __P((rl_icppfunc_t *));
|
||||
static void restore_directory_hook __P((rl_icppfunc_t));
|
||||
|
||||
static void cleanup_expansion_error __P((void));
|
||||
static void maybe_make_readline_line __P((char *));
|
||||
@@ -151,6 +153,7 @@ static int return_zero __P((const char *));
|
||||
|
||||
static char *bash_dequote_filename __P((char *, int));
|
||||
static char *quote_word_break_chars __P((char *));
|
||||
static void set_filename_bstab __P((const char *));
|
||||
static char *bash_quote_filename __P((char *, int, char *));
|
||||
|
||||
static int putx __P((int));
|
||||
@@ -251,12 +254,20 @@ int dircomplete_spelling = 0;
|
||||
/* Expand directory names during word/filename completion. */
|
||||
int dircomplete_expand = 0;
|
||||
|
||||
/* When non-zero, perform `normal' shell quoting on completed filenames
|
||||
even when the completed name contains a directory name with a shell
|
||||
variable referene, so dollar signs in a filename get quoted appropriately.
|
||||
Set to zero to remove dollar sign (and braces or parens as needed) from
|
||||
the set of characters that will be quoted. */
|
||||
int complete_fullquote = 1;
|
||||
|
||||
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
|
||||
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
|
||||
/* )) */
|
||||
|
||||
static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
|
||||
static char *custom_filename_quote_characters = 0;
|
||||
static char filename_bstab[256];
|
||||
|
||||
static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
@@ -541,6 +552,7 @@ initialize_readline ()
|
||||
|
||||
/* characters that need to be quoted when appearing in filenames. */
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
rl_filename_quoting_function = bash_quote_filename;
|
||||
rl_filename_dequoting_function = bash_dequote_filename;
|
||||
@@ -589,6 +601,7 @@ bashline_reset ()
|
||||
rl_completion_entry_function = NULL;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
set_directory_hook ();
|
||||
}
|
||||
@@ -1311,6 +1324,7 @@ attempt_shell_completion (text, start, end)
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
/* Determine if this could be a command word. It is if it appears at
|
||||
the start of the line (ignoring preceding whitespace), or if it
|
||||
@@ -2799,6 +2813,56 @@ restore_directory_hook (hookf)
|
||||
rl_directory_rewrite_hook = hookf;
|
||||
}
|
||||
|
||||
static int
|
||||
bash_filename_stat_hook (dirname)
|
||||
char **dirname;
|
||||
{
|
||||
char *local_dirname, *new_dirname, *t;
|
||||
int should_expand_dirname, return_value;
|
||||
WORD_LIST *wl;
|
||||
struct stat sb;
|
||||
|
||||
local_dirname = *dirname;
|
||||
should_expand_dirname = return_value = 0;
|
||||
if (t = mbschr (local_dirname, '$'))
|
||||
should_expand_dirname = '$';
|
||||
else if (t = mbschr (local_dirname, '`')) /* XXX */
|
||||
should_expand_dirname = '`';
|
||||
|
||||
#if defined (HAVE_LSTAT)
|
||||
if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
|
||||
#else
|
||||
if (should_expand_dirname && stat (local_dirname, &sb) == 0)
|
||||
#endif
|
||||
should_expand_dirname = 0;
|
||||
|
||||
if (should_expand_dirname)
|
||||
{
|
||||
new_dirname = savestring (local_dirname);
|
||||
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
|
||||
if (wl)
|
||||
{
|
||||
free (new_dirname);
|
||||
new_dirname = string_list (wl);
|
||||
/* Tell the completer we actually expanded something and change
|
||||
*dirname only if we expanded to something non-null -- stat
|
||||
behaves unpredictably when passed null or empty strings */
|
||||
if (new_dirname && *new_dirname)
|
||||
{
|
||||
*dirname = new_dirname;
|
||||
return_value = STREQ (local_dirname, *dirname) == 0;
|
||||
}
|
||||
free (local_dirname);
|
||||
free (new_dirname);
|
||||
dispose_words (wl);
|
||||
}
|
||||
else
|
||||
free (new_dirname);
|
||||
}
|
||||
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
/* Handle symbolic link references and other directory name
|
||||
expansions while hacking completion. This should return 1 if it modifies
|
||||
the DIRNAME argument, 0 otherwise. It should make sure not to modify
|
||||
@@ -2872,6 +2936,7 @@ bash_directory_completion_hook (dirname)
|
||||
}
|
||||
custom_filename_quote_characters[j] = '\0';
|
||||
rl_filename_quote_characters = custom_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3494,6 +3559,20 @@ quote_word_break_chars (text)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Use characters in STRING to populate the table of characters that should
|
||||
be backslash-quoted. The table will be used for sh_backslash_quote from
|
||||
this file. */
|
||||
static void
|
||||
set_filename_bstab (string)
|
||||
const char *string;
|
||||
{
|
||||
const char *s;
|
||||
|
||||
memset (filename_bstab, 0, sizeof (filename_bstab));
|
||||
for (s = string; s && *s; s++)
|
||||
filename_bstab[*s] = 1;
|
||||
}
|
||||
|
||||
/* Quote a filename using double quotes, single quotes, or backslashes
|
||||
depending on the value of completion_quoting_style. If we're
|
||||
completing using backslashes, we need to quote some additional
|
||||
@@ -3559,7 +3638,7 @@ bash_quote_filename (s, rtype, qcp)
|
||||
rtext = sh_single_quote (mtext);
|
||||
break;
|
||||
case COMPLETE_BSQUOTE:
|
||||
rtext = sh_backslash_quote (mtext);
|
||||
rtext = sh_backslash_quote (mtext, complete_fullquote ? 0 : filename_bstab);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+89
-6
@@ -121,7 +121,6 @@ static int bash_directory_completion_hook __P((char **));
|
||||
static int filename_completion_ignore __P((char **));
|
||||
static int bash_push_line __P((void));
|
||||
|
||||
static void set_directory_hook __P((void));
|
||||
static rl_icppfunc_t *save_directory_hook __P((void));
|
||||
static void reset_directory_hook __P((rl_icppfunc_t *));
|
||||
|
||||
@@ -152,6 +151,7 @@ static int return_zero __P((const char *));
|
||||
|
||||
static char *bash_dequote_filename __P((char *, int));
|
||||
static char *quote_word_break_chars __P((char *));
|
||||
static void set_filename_bstab __P((const char *));
|
||||
static char *bash_quote_filename __P((char *, int, char *));
|
||||
|
||||
static int putx __P((int));
|
||||
@@ -250,7 +250,14 @@ int force_fignore = 1;
|
||||
int dircomplete_spelling = 0;
|
||||
|
||||
/* Expand directory names during word/filename completion. */
|
||||
int dircomplete_expand = 1;
|
||||
int dircomplete_expand = 0;
|
||||
|
||||
/* When non-zero, perform `normal' shell quoting on completed filenames
|
||||
even when the completed name contains a directory name with a shell
|
||||
variable referene, so dollar signs in a filename get quoted appropriately.
|
||||
Set to zero to remove dollar sign (and braces or parens as needed) from
|
||||
the set of characters that will be quoted. */
|
||||
int complete_fullquote = 1;
|
||||
|
||||
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
|
||||
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
|
||||
@@ -258,6 +265,7 @@ static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
|
||||
|
||||
static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
|
||||
static char *custom_filename_quote_characters = 0;
|
||||
static char filename_bstab[256];
|
||||
|
||||
static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
@@ -542,6 +550,7 @@ initialize_readline ()
|
||||
|
||||
/* characters that need to be quoted when appearing in filenames. */
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
rl_filename_quoting_function = bash_quote_filename;
|
||||
rl_filename_dequoting_function = bash_dequote_filename;
|
||||
@@ -590,6 +599,7 @@ bashline_reset ()
|
||||
rl_completion_entry_function = NULL;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
set_directory_hook ();
|
||||
}
|
||||
@@ -1312,6 +1322,7 @@ attempt_shell_completion (text, start, end)
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
|
||||
/* Determine if this could be a command word. It is if it appears at
|
||||
the start of the line (ignoring preceding whitespace), or if it
|
||||
@@ -2755,13 +2766,20 @@ bash_filename_rewrite_hook (fname, fnlen)
|
||||
}
|
||||
|
||||
/* Functions to save and restore the appropriate directory hook */
|
||||
static void
|
||||
/* This is not static so the shopt code can call it */
|
||||
void
|
||||
set_directory_hook ()
|
||||
{
|
||||
if (dircomplete_expand)
|
||||
rl_directory_completion_hook = bash_directory_completion_hook;
|
||||
{
|
||||
rl_directory_completion_hook = bash_directory_completion_hook;
|
||||
rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
|
||||
}
|
||||
else
|
||||
rl_directory_rewrite_hook = bash_directory_completion_hook;
|
||||
{
|
||||
rl_directory_rewrite_hook = bash_directory_completion_hook;
|
||||
rl_directory_completion_hook = (rl_icppfunc_t *)0;
|
||||
}
|
||||
}
|
||||
|
||||
static rl_icppfunc_t *
|
||||
@@ -2793,6 +2811,56 @@ restore_directory_hook (hookf)
|
||||
rl_directory_rewrite_hook = hookf;
|
||||
}
|
||||
|
||||
static int
|
||||
bash_directory_stat_hook (dirname)
|
||||
char **dirname;
|
||||
{
|
||||
char *local_dirname, *new_dirname, *t;
|
||||
int should_expand_dirname, return_value;
|
||||
WORD_LIST *wl;
|
||||
struct stat sb;
|
||||
|
||||
local_dirname = *dirname;
|
||||
should_expand_dirname = return_value = 0;
|
||||
if (t = mbschr (local_dirname, '$'))
|
||||
should_expand_dirname = '$';
|
||||
else if (t = mbschr (local_dirname, '`')) /* XXX */
|
||||
should_expand_dirname = '`';
|
||||
|
||||
#if defined (HAVE_LSTAT)
|
||||
if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
|
||||
#else
|
||||
if (should_expand_dirname && stat (local_dirname, &sb) == 0)
|
||||
#endif
|
||||
should_expand_dirname = 0;
|
||||
|
||||
if (should_expand_dirname)
|
||||
{
|
||||
new_dirname = savestring (local_dirname);
|
||||
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
|
||||
if (wl)
|
||||
{
|
||||
free (new_dirname);
|
||||
new_dirname = string_list (wl);
|
||||
/* Tell the completer we actually expanded something and change
|
||||
*dirname only if we expanded to something non-null -- stat
|
||||
behaves unpredictably when passed null or empty strings */
|
||||
if (new_dirname && *new_dirname)
|
||||
{
|
||||
*dirname = new_dirname;
|
||||
return_value = STREQ (local_dirname, *dirname) == 0;
|
||||
}
|
||||
free (local_dirname);
|
||||
free (new_dirname);
|
||||
dispose_words (wl);
|
||||
}
|
||||
else
|
||||
free (new_dirname);
|
||||
}
|
||||
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
/* Handle symbolic link references and other directory name
|
||||
expansions while hacking completion. This should return 1 if it modifies
|
||||
the DIRNAME argument, 0 otherwise. It should make sure not to modify
|
||||
@@ -2866,6 +2934,7 @@ bash_directory_completion_hook (dirname)
|
||||
}
|
||||
custom_filename_quote_characters[j] = '\0';
|
||||
rl_filename_quote_characters = custom_filename_quote_characters;
|
||||
set_filename_bstab (rl_filename_quote_characters);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3488,6 +3557,20 @@ quote_word_break_chars (text)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Use characters in STRING to populate the table of characters that should
|
||||
be backslash-quoted. The table will be used for sh_backslash_quote from
|
||||
this file. */
|
||||
static void
|
||||
set_filename_bstab (string)
|
||||
const char *string;
|
||||
{
|
||||
const char *s;
|
||||
|
||||
memset (filename_bstab, 0, sizeof (filename_bstab));
|
||||
for (s = string; s && *s; s++)
|
||||
filename_bstab[*s] = 1;
|
||||
}
|
||||
|
||||
/* Quote a filename using double quotes, single quotes, or backslashes
|
||||
depending on the value of completion_quoting_style. If we're
|
||||
completing using backslashes, we need to quote some additional
|
||||
@@ -3553,7 +3636,7 @@ bash_quote_filename (s, rtype, qcp)
|
||||
rtext = sh_single_quote (mtext);
|
||||
break;
|
||||
case COMPLETE_BSQUOTE:
|
||||
rtext = sh_backslash_quote (mtext);
|
||||
rtext = sh_backslash_quote (mtext, complete_fullquote ? 0 : filename_bstab);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -75,8 +75,8 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
|
||||
|
||||
if (real_start == real_end)
|
||||
{
|
||||
x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero)
|
||||
: sh_backslash_quote (array[0]);
|
||||
x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero, 0)
|
||||
: sh_backslash_quote (array[0], 0);
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
|
||||
if (start == end)
|
||||
{
|
||||
x = savestring (array[start] + gcd_zero);
|
||||
subterm = sh_backslash_quote (x);
|
||||
subterm = sh_backslash_quote (x, 0);
|
||||
free (x);
|
||||
}
|
||||
else
|
||||
@@ -126,7 +126,7 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
|
||||
x = (char *)xmalloc (tlen + 1);
|
||||
strncpy (x, array[start] + gcd_zero, tlen);
|
||||
x[tlen] = '\0';
|
||||
subterm = sh_backslash_quote (x);
|
||||
subterm = sh_backslash_quote (x, 0);
|
||||
free (x);
|
||||
result_size += strlen (subterm) + 1;
|
||||
result = (char *)xrealloc (result, result_size);
|
||||
|
||||
+1
-1
@@ -553,7 +553,7 @@ printf_builtin (list)
|
||||
else if (ansic_shouldquote (p))
|
||||
xp = ansic_quote (p, 0, (int *)0);
|
||||
else
|
||||
xp = sh_backslash_quote (p);
|
||||
xp = sh_backslash_quote (p, 0);
|
||||
if (xp)
|
||||
{
|
||||
/* Use printstr to get fieldwidth and precision right. */
|
||||
|
||||
@@ -100,6 +100,7 @@ extern int hist_verify, history_reediting, perform_hostname_completion;
|
||||
extern int no_empty_command_completion;
|
||||
extern int force_fignore;
|
||||
extern int dircomplete_spelling, dircomplete_expand;
|
||||
extern int complete_fullquote;
|
||||
|
||||
extern int enable_hostname_completion __P((int));
|
||||
#endif
|
||||
@@ -159,6 +160,7 @@ static struct {
|
||||
{ "compat40", &shopt_compat40, set_compatibility_level },
|
||||
{ "compat41", &shopt_compat41, set_compatibility_level },
|
||||
#if defined (READLINE)
|
||||
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
|
||||
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
|
||||
{ "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
|
||||
+21
-2
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@po.cwru.edu
|
||||
.\"
|
||||
.\" Last Change: Fri Sep 2 14:19:38 EDT 2011
|
||||
.\" Last Change: Thu Sep 8 09:39:24 EDT 2011
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2011 September 2" "GNU Bash 4.2"
|
||||
.TH BASH 1 "2011 September 8" "GNU Bash 4.2"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -8993,6 +8993,25 @@ parameter expansion as a special character. The single quotes must match
|
||||
quoted. This is the behavior of posix mode through version 4.1.
|
||||
The default bash behavior remains as in previous versions.
|
||||
.TP 8
|
||||
.B complete_fullquote
|
||||
If set,
|
||||
.B bash
|
||||
quotes all shell metacharacters in filenames and directory names when
|
||||
performing completion.
|
||||
If not set,
|
||||
.B bash
|
||||
removes metacharacters such as the dollar sign from the set of
|
||||
characters that will be quoted in completed filenames
|
||||
when these metacharacters appear in shell variable references in words to be
|
||||
completed.
|
||||
This means that dollar signs in variable names that expand to directories
|
||||
will not be quoted;
|
||||
however, any dollar signs appearing in filenames will not be quoted, either.
|
||||
This is active only when bash is using backslashes to quote completed
|
||||
filenames.
|
||||
This variable is set by default, which is the default bash behavior in
|
||||
versions through 4.2.
|
||||
.TP 8
|
||||
.B direxpand
|
||||
If set,
|
||||
.B bash
|
||||
|
||||
@@ -4562,6 +4562,23 @@ parameter expansion as a special character. The single quotes must match
|
||||
quoted. This is the behavior of @sc{posix} mode through version 4.1.
|
||||
The default Bash behavior remains as in previous versions.
|
||||
|
||||
@item complete_fullquote
|
||||
If set, Bash
|
||||
quotes all shell metacharacters in filenames and directory names when
|
||||
performing completion.
|
||||
If not set, Bash
|
||||
removes metacharacters such as the dollar sign from the set of
|
||||
characters that will be quoted in completed filenames
|
||||
when these metacharacters appear in shell variable references in words to be
|
||||
completed.
|
||||
This means that dollar signs in variable names that expand to directories
|
||||
will not be quoted;
|
||||
however, any dollar signs appearing in filenames will not be quoted, either.
|
||||
This is active only when bash is using backslashes to quote completed
|
||||
filenames.
|
||||
This variable is set by default, which is the default Bash behavior in
|
||||
versions through 4.2.
|
||||
|
||||
@item direxpand
|
||||
If set, Bash
|
||||
replaces directory names with the results of word expansion when performing
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2011 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Fri Sep 2 14:19:16 EDT 2011
|
||||
@set LASTCHANGE Thu Sep 8 09:39:10 EDT 2011
|
||||
|
||||
@set EDITION 4.2
|
||||
@set VERSION 4.2
|
||||
@set UPDATED 2 September 2011
|
||||
@set UPDATED 8 September 2011
|
||||
@set UPDATED-MONTH September 2011
|
||||
|
||||
@@ -312,7 +312,7 @@ extern char *sh_single_quote __P((const char *));
|
||||
extern char *sh_double_quote __P((const char *));
|
||||
extern char *sh_mkdoublequoted __P((const char *, int, int));
|
||||
extern char *sh_un_double_quote __P((char *));
|
||||
extern char *sh_backslash_quote __P((char *));
|
||||
extern char *sh_backslash_quote __P((char *, const char *));
|
||||
extern char *sh_backslash_quote_for_double_quotes __P((char *));
|
||||
extern int sh_contains_shell_metas __P((char *));
|
||||
|
||||
|
||||
+54
-37
@@ -32,6 +32,50 @@
|
||||
#include "syntax.h"
|
||||
#include <xmalloc.h>
|
||||
|
||||
/* Default set of characters that should be backslash-quoted in strings */
|
||||
static const char bstab[256] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 0, 0, 0, 0, 0, /* TAB, NL */
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
1, 1, 1, 0, 1, 0, 1, 1, /* SPACE, !, DQUOTE, DOL, AMP, SQUOTE */
|
||||
1, 1, 1, 0, 1, 0, 0, 0, /* LPAR, RPAR, STAR, COMMA */
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 1, 0, 1, 1, /* SEMI, LESSTHAN, GREATERTHAN, QUEST */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 1, 1, 1, 0, /* LBRACK, BS, RBRACK, CARAT */
|
||||
|
||||
1, 0, 0, 0, 0, 0, 0, 0, /* BACKQ */
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 1, 1, 0, 0, /* LBRACE, BAR, RBRACE */
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions for quoting strings to be re-read as input */
|
||||
@@ -165,51 +209,24 @@ sh_un_double_quote (string)
|
||||
going through the shell parser, which will protect the internal
|
||||
quoting characters. */
|
||||
char *
|
||||
sh_backslash_quote (string)
|
||||
sh_backslash_quote (string, table)
|
||||
char *string;
|
||||
char *table;
|
||||
{
|
||||
int c;
|
||||
char *result, *r, *s;
|
||||
char *result, *r, *s, *backslash_table;
|
||||
|
||||
result = (char *)xmalloc (2 * strlen (string) + 1);
|
||||
|
||||
backslash_table = table ? table : bstab;
|
||||
for (r = result, s = string; s && (c = *s); s++)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case ' ': case '\t': case '\n': /* IFS white space */
|
||||
case '\'': case '"': case '\\': /* quoting chars */
|
||||
case '|': case '&': case ';': /* shell metacharacters */
|
||||
case '(': case ')': case '<': case '>':
|
||||
case '!': case '{': case '}': /* reserved words */
|
||||
case '*': case '[': case '?': case ']': /* globbing chars */
|
||||
case '^':
|
||||
case '$': case '`': /* expansion chars */
|
||||
case ',': /* brace expansion */
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
break;
|
||||
#if 0
|
||||
case '~': /* tilde expansion */
|
||||
if (s == string || s[-1] == '=' || s[-1] == ':')
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
break;
|
||||
|
||||
case CTLESC: case CTLNUL: /* internal quoting characters */
|
||||
*r++ = CTLESC; /* could be '\\'? */
|
||||
*r++ = c;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case '#': /* comment char */
|
||||
if (s == string)
|
||||
*r++ = '\\';
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
*r++ = c;
|
||||
break;
|
||||
}
|
||||
|
||||
if (backslash_table[c] == 1)
|
||||
*r++ = '\\';
|
||||
else if (c == '#' && s == string) /* comment char */
|
||||
*r++ = '\\';
|
||||
*r++ = c;
|
||||
}
|
||||
|
||||
*r = '\0';
|
||||
|
||||
+332
-477
File diff suppressed because it is too large
Load Diff
@@ -101,10 +101,6 @@ kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill
|
||||
./errors1.sub: line 1: .: -i: invalid option
|
||||
.: usage: . filename [arguments]
|
||||
./errors1.sub: line 9: shift: -4: shift count out of range
|
||||
./errors1.sub: line 5: return: -1: invalid option
|
||||
return: usage: return [n]
|
||||
./errors1.sub: line 14: break: -1: loop count out of range
|
||||
./errors1.sub: line 20: return: -2: invalid option
|
||||
return: usage: return [n]
|
||||
after f
|
||||
./errors.tests: line 264: `!!': not a valid identifier
|
||||
|
||||
Reference in New Issue
Block a user