mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-09 19:50:32 +02:00
commit bash-20110701 snapshot
This commit is contained in:
+57
-9
@@ -121,6 +121,10 @@ 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 *));
|
||||
|
||||
static void cleanup_expansion_error __P((void));
|
||||
static void maybe_make_readline_line __P((char *));
|
||||
static void set_up_new_line __P((char *));
|
||||
@@ -245,6 +249,9 @@ int force_fignore = 1;
|
||||
/* Perform spelling correction on directory names during word completion */
|
||||
int dircomplete_spelling = 0;
|
||||
|
||||
/* Expand directory names during word/filename completion. */
|
||||
int dircomplete_expand = 0;
|
||||
|
||||
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
|
||||
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
|
||||
/* )) */
|
||||
@@ -506,7 +513,7 @@ initialize_readline ()
|
||||
|
||||
/* Tell the completer that we might want to follow symbolic links or
|
||||
do other expansion on directory names. */
|
||||
rl_directory_rewrite_hook = bash_directory_completion_hook;
|
||||
set_directory_hook ();
|
||||
|
||||
rl_filename_rewrite_hook = bash_filename_rewrite_hook;
|
||||
|
||||
@@ -581,9 +588,10 @@ bashline_reset ()
|
||||
tilde_initialize ();
|
||||
rl_attempted_completion_function = attempt_shell_completion;
|
||||
rl_completion_entry_function = NULL;
|
||||
rl_directory_rewrite_hook = bash_directory_completion_hook;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
rl_filename_quote_characters = default_filename_quote_characters;
|
||||
|
||||
set_directory_hook ();
|
||||
}
|
||||
|
||||
/* Contains the line to push into readline. */
|
||||
@@ -2746,6 +2754,45 @@ bash_filename_rewrite_hook (fname, fnlen)
|
||||
return conv;
|
||||
}
|
||||
|
||||
/* Functions to save and restore the appropriate directory hook */
|
||||
static void
|
||||
set_directory_hook ()
|
||||
{
|
||||
if (dircomplete_expand)
|
||||
rl_directory_completion_hook = bash_directory_completion_hook;
|
||||
else
|
||||
rl_directory_rewrite_hook = bash_directory_completion_hook;
|
||||
}
|
||||
|
||||
static rl_icppfunc_t *
|
||||
save_directory_hook ()
|
||||
{
|
||||
rl_icppfunc_t *ret;
|
||||
|
||||
if (dircomplete_expand)
|
||||
{
|
||||
ret = rl_directory_completion_hook;
|
||||
rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = rl_directory_rewrite_hook;
|
||||
rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
restore_directory_hook (hookf)
|
||||
rl_icppfunc_t *hookf;
|
||||
{
|
||||
if (dircomplete_expand)
|
||||
rl_directory_completion_hook = hookf;
|
||||
else
|
||||
rl_directory_rewrite_hook = hookf;
|
||||
}
|
||||
|
||||
/* 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
|
||||
@@ -3083,12 +3130,13 @@ bash_complete_filename_internal (what_to_do)
|
||||
|
||||
orig_func = rl_completion_entry_function;
|
||||
orig_attempt_func = rl_attempted_completion_function;
|
||||
orig_dir_func = rl_directory_rewrite_hook;
|
||||
orig_ignore_func = rl_ignore_some_completions_function;
|
||||
orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
|
||||
|
||||
orig_dir_func = save_directory_hook ();
|
||||
|
||||
rl_completion_entry_function = rl_filename_completion_function;
|
||||
rl_attempted_completion_function = (rl_completion_func_t *)NULL;
|
||||
rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
|
||||
rl_ignore_some_completions_function = filename_completion_ignore;
|
||||
rl_completer_word_break_characters = " \t\n\"\'";
|
||||
|
||||
@@ -3096,10 +3144,11 @@ bash_complete_filename_internal (what_to_do)
|
||||
|
||||
rl_completion_entry_function = orig_func;
|
||||
rl_attempted_completion_function = orig_attempt_func;
|
||||
rl_directory_rewrite_hook = orig_dir_func;
|
||||
rl_ignore_some_completions_function = orig_ignore_func;
|
||||
rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
|
||||
|
||||
restore_directory_hook (orig_dir_func);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -3540,10 +3589,7 @@ static int
|
||||
putx(c)
|
||||
int c;
|
||||
{
|
||||
int x;
|
||||
|
||||
x = putc (c, rl_outstream);
|
||||
return (x);
|
||||
return (putc (c, rl_outstream));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -3786,7 +3832,9 @@ bash_dequote_text (text)
|
||||
static int
|
||||
bash_event_hook ()
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
itrace("bash_event_hook");
|
||||
#endif
|
||||
CHECK_TERMSIG;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user