Roman Rakus 7b8ddd
			     BASH PATCH REPORT
Roman Rakus 7b8ddd
			     =================
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
Bash-Release:	4.2
Roman Rakus 7b8ddd
Patch-ID:	bash42-029
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
Bug-Reported-by:	"Michael Kalisz" <michael@kalisz.homelinux.net>
Roman Rakus 7b8ddd
Bug-Reference-ID:	<50241.78.69.11.112.1298585641.squirrel@kalisz.homelinux.net>
Roman Rakus 7b8ddd
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00274.html
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
Bug-Description:
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
Bash-4.2 tries to leave completed directory names as the user typed them,
Roman Rakus 7b8ddd
without expanding them to a full pathname.  One effect of this is that
Roman Rakus 7b8ddd
shell variables used in pathnames being completed (e.g., $HOME) are left
Roman Rakus 7b8ddd
unchanged, but the `$' is quoted by readline because it is a special
Roman Rakus 7b8ddd
character to the shell.
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
This patch introduces two things:
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
1.  A new shell option, `direxpand', which, if set, attempts to emulate the
Roman Rakus 7b8ddd
    bash-4.1 behavior of expanding words to full pathnames during
Roman Rakus 7b8ddd
    completion;
Roman Rakus 7b8ddd
2.  A set of heuristics that reduce the number of times special characters
Roman Rakus 7b8ddd
    such as `$' are quoted when the directory name is not expanded.
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
Patch (apply with `patch -p0'):
Roman Rakus 7b8ddd
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/bashline.c ./bashline.c
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/bashline.c	2011-01-16 15:32:47.000000000 -0500
Roman Rakus 7b8ddd
--- ./bashline.c	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 122,125 ****
Roman Rakus 7b8ddd
--- 122,128 ----
Roman Rakus 7b8ddd
  static int bash_push_line __P((void));
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ static rl_icppfunc_t *save_directory_hook __P((void));
Roman Rakus 7b8ddd
+ static void reset_directory_hook __P((rl_icppfunc_t *));
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  static void cleanup_expansion_error __P((void));
Roman Rakus 7b8ddd
  static void maybe_make_readline_line __P((char *));
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 244,251 ****
Roman Rakus 7b8ddd
--- 247,261 ----
Roman Rakus 7b8ddd
  int dircomplete_spelling = 0;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ /* Expand directory names during word/filename completion. */
Roman Rakus 7b8ddd
+ int dircomplete_expand = 0;
Roman Rakus 7b8ddd
+ int dircomplete_expand_relpath = 0;
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
Roman Rakus 7b8ddd
  static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
Roman Rakus 7b8ddd
  /* )) */
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~";	/*}*/
Roman Rakus 7b8ddd
+ static char *custom_filename_quote_characters = 0;
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 502,506 ****
Roman Rakus 7b8ddd
    /* Tell the completer that we might want to follow symbolic links or
Roman Rakus 7b8ddd
       do other expansion on directory names. */
Roman Rakus 7b8ddd
!   rl_directory_rewrite_hook = bash_directory_completion_hook;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    rl_filename_rewrite_hook = bash_filename_rewrite_hook;
Roman Rakus 7b8ddd
--- 512,516 ----
Roman Rakus 7b8ddd
    /* Tell the completer that we might want to follow symbolic links or
Roman Rakus 7b8ddd
       do other expansion on directory names. */
Roman Rakus 7b8ddd
!   set_directory_hook ();
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    rl_filename_rewrite_hook = bash_filename_rewrite_hook;
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 530,534 ****
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    /* characters that need to be quoted when appearing in filenames. */
Roman Rakus 7b8ddd
!   rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~";	/*}*/
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    rl_filename_quoting_function = bash_quote_filename;
Roman Rakus 7b8ddd
--- 540,544 ----
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    /* characters that need to be quoted when appearing in filenames. */
Roman Rakus 7b8ddd
!   rl_filename_quote_characters = default_filename_quote_characters;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    rl_filename_quoting_function = bash_quote_filename;
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 565,570 ****
Roman Rakus 7b8ddd
    rl_attempted_completion_function = attempt_shell_completion;
Roman Rakus 7b8ddd
    rl_completion_entry_function = NULL;
Roman Rakus 7b8ddd
-   rl_directory_rewrite_hook = bash_directory_completion_hook;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = filename_completion_ignore;
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
--- 575,582 ----
Roman Rakus 7b8ddd
    rl_attempted_completion_function = attempt_shell_completion;
Roman Rakus 7b8ddd
    rl_completion_entry_function = NULL;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = filename_completion_ignore;
Roman Rakus 7b8ddd
+   rl_filename_quote_characters = default_filename_quote_characters;
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+   set_directory_hook ();
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 1280,1283 ****
Roman Rakus 7b8ddd
--- 1292,1298 ----
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = filename_completion_ignore;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+   rl_filename_quote_characters = default_filename_quote_characters;
Roman Rakus 7b8ddd
+   set_directory_hook ();
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
    /* Determine if this could be a command word.  It is if it appears at
Roman Rakus 7b8ddd
       the start of the line (ignoring preceding whitespace), or if it
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 1592,1595 ****
Roman Rakus 7b8ddd
--- 1607,1616 ----
Roman Rakus 7b8ddd
  	  else
Roman Rakus 7b8ddd
  	    {
Roman Rakus 7b8ddd
+ 	     if (dircomplete_expand && dot_or_dotdot (filename_hint))
Roman Rakus 7b8ddd
+ 		{
Roman Rakus 7b8ddd
+ 		  dircomplete_expand = 0;
Roman Rakus 7b8ddd
+ 		  set_directory_hook ();
Roman Rakus 7b8ddd
+ 		  dircomplete_expand = 1;
Roman Rakus 7b8ddd
+ 		}
Roman Rakus 7b8ddd
  	      mapping_over = 4;
Roman Rakus 7b8ddd
  	      goto inner;
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 1792,1795 ****
Roman Rakus 7b8ddd
--- 1813,1819 ----
Roman Rakus 7b8ddd
   inner:
Roman Rakus 7b8ddd
    val = rl_filename_completion_function (filename_hint, istate);
Roman Rakus 7b8ddd
+   if (mapping_over == 4 && dircomplete_expand)
Roman Rakus 7b8ddd
+     set_directory_hook ();
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
    istate = 1;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2694,2697 ****
Roman Rakus 7b8ddd
--- 2718,2767 ----
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ /* Functions to save and restore the appropriate directory hook */
Roman Rakus 7b8ddd
+ /* This is not static so the shopt code can call it */
Roman Rakus 7b8ddd
+ void
Roman Rakus 7b8ddd
+ set_directory_hook ()
Roman Rakus 7b8ddd
+ {
Roman Rakus 7b8ddd
+   if (dircomplete_expand)
Roman Rakus 7b8ddd
+     {
Roman Rakus 7b8ddd
+       rl_directory_completion_hook = bash_directory_completion_hook;
Roman Rakus 7b8ddd
+       rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
Roman Rakus 7b8ddd
+     }
Roman Rakus 7b8ddd
+   else
Roman Rakus 7b8ddd
+     {
Roman Rakus 7b8ddd
+       rl_directory_rewrite_hook = bash_directory_completion_hook;
Roman Rakus 7b8ddd
+       rl_directory_completion_hook = (rl_icppfunc_t *)0;
Roman Rakus 7b8ddd
+     }
Roman Rakus 7b8ddd
+ }
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+ static rl_icppfunc_t *
Roman Rakus 7b8ddd
+ save_directory_hook ()
Roman Rakus 7b8ddd
+ {
Roman Rakus 7b8ddd
+   rl_icppfunc_t *ret;
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+   if (dircomplete_expand)
Roman Rakus 7b8ddd
+     {
Roman Rakus 7b8ddd
+       ret = rl_directory_completion_hook;
Roman Rakus 7b8ddd
+       rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
Roman Rakus 7b8ddd
+     }
Roman Rakus 7b8ddd
+   else
Roman Rakus 7b8ddd
+     {
Roman Rakus 7b8ddd
+       ret = rl_directory_rewrite_hook;
Roman Rakus 7b8ddd
+       rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
Roman Rakus 7b8ddd
+     }
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+   return ret;
Roman Rakus 7b8ddd
+ }
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+ static void
Roman Rakus 7b8ddd
+ restore_directory_hook (hookf)
Roman Rakus 7b8ddd
+      rl_icppfunc_t *hookf;
Roman Rakus 7b8ddd
+ {
Roman Rakus 7b8ddd
+   if (dircomplete_expand)
Roman Rakus 7b8ddd
+     rl_directory_completion_hook = hookf;
Roman Rakus 7b8ddd
+   else
Roman Rakus 7b8ddd
+     rl_directory_rewrite_hook = hookf;
Roman Rakus 7b8ddd
+ }
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  /* Handle symbolic link references and other directory name
Roman Rakus 7b8ddd
     expansions while hacking completion.  This should return 1 if it modifies
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2703,2720 ****
Roman Rakus 7b8ddd
  {
Roman Rakus 7b8ddd
    char *local_dirname, *new_dirname, *t;
Roman Rakus 7b8ddd
!   int return_value, should_expand_dirname;
Roman Rakus 7b8ddd
    WORD_LIST *wl;
Roman Rakus 7b8ddd
    struct stat sb;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
!   return_value = should_expand_dirname = 0;
Roman Rakus 7b8ddd
    local_dirname = *dirname;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
!   if (mbschr (local_dirname, '$'))
Roman Rakus 7b8ddd
!     should_expand_dirname = 1;
Roman Rakus 7b8ddd
    else
Roman Rakus 7b8ddd
      {
Roman Rakus 7b8ddd
        t = mbschr (local_dirname, '`');
Roman Rakus 7b8ddd
        if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
Roman Rakus 7b8ddd
! 	should_expand_dirname = 1;
Roman Rakus 7b8ddd
      }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
--- 2773,2801 ----
Roman Rakus 7b8ddd
  {
Roman Rakus 7b8ddd
    char *local_dirname, *new_dirname, *t;
Roman Rakus 7b8ddd
!   int return_value, should_expand_dirname, nextch, closer;
Roman Rakus 7b8ddd
    WORD_LIST *wl;
Roman Rakus 7b8ddd
    struct stat sb;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
!   return_value = should_expand_dirname = nextch = closer = 0;
Roman Rakus 7b8ddd
    local_dirname = *dirname;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
!   if (t = mbschr (local_dirname, '$'))
Roman Rakus 7b8ddd
!     {
Roman Rakus 7b8ddd
!       should_expand_dirname = '$';
Roman Rakus 7b8ddd
!       nextch = t[1];
Roman Rakus 7b8ddd
!       /* Deliberately does not handle the deprecated $[...] arithmetic
Roman Rakus 7b8ddd
! 	 expansion syntax */
Roman Rakus 7b8ddd
!       if (nextch == '(')
Roman Rakus 7b8ddd
! 	closer = ')';
Roman Rakus 7b8ddd
!       else if (nextch == '{')
Roman Rakus 7b8ddd
! 	closer = '}';
Roman Rakus 7b8ddd
!       else
Roman Rakus 7b8ddd
! 	nextch = 0;
Roman Rakus 7b8ddd
!     }
Roman Rakus 7b8ddd
    else
Roman Rakus 7b8ddd
      {
Roman Rakus 7b8ddd
        t = mbschr (local_dirname, '`');
Roman Rakus 7b8ddd
        if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
Roman Rakus 7b8ddd
! 	should_expand_dirname = '`';
Roman Rakus 7b8ddd
      }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2740,2743 ****
Roman Rakus 7b8ddd
--- 2821,2841 ----
Roman Rakus 7b8ddd
  	  dispose_words (wl);
Roman Rakus 7b8ddd
  	  local_dirname = *dirname;
Roman Rakus 7b8ddd
+ 	  /* XXX - change rl_filename_quote_characters here based on
Roman Rakus 7b8ddd
+ 	     should_expand_dirname/nextch/closer.  This is the only place
Roman Rakus 7b8ddd
+ 	     custom_filename_quote_characters is modified. */
Roman Rakus 7b8ddd
+ 	  if (rl_filename_quote_characters && *rl_filename_quote_characters)
Roman Rakus 7b8ddd
+ 	    {
Roman Rakus 7b8ddd
+ 	      int i, j, c;
Roman Rakus 7b8ddd
+ 	      i = strlen (default_filename_quote_characters);
Roman Rakus 7b8ddd
+ 	      custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
Roman Rakus 7b8ddd
+ 	      for (i = j = 0; c = default_filename_quote_characters[i]; i++)
Roman Rakus 7b8ddd
+ 		{
Roman Rakus 7b8ddd
+ 		  if (c == should_expand_dirname || c == nextch || c == closer)
Roman Rakus 7b8ddd
+ 		    continue;
Roman Rakus 7b8ddd
+ 		  custom_filename_quote_characters[j++] = c;
Roman Rakus 7b8ddd
+ 		}
Roman Rakus 7b8ddd
+ 	      custom_filename_quote_characters[j] = '\0';
Roman Rakus 7b8ddd
+ 	      rl_filename_quote_characters = custom_filename_quote_characters;
Roman Rakus 7b8ddd
+ 	    }
Roman Rakus 7b8ddd
  	}
Roman Rakus 7b8ddd
        else
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2759,2762 ****
Roman Rakus 7b8ddd
--- 2857,2871 ----
Roman Rakus 7b8ddd
      }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+   /* no_symbolic_links == 0 -> use (default) logical view of the file system.
Roman Rakus 7b8ddd
+      local_dirname[0] == '.' && local_dirname[1] == '/' means files in the
Roman Rakus 7b8ddd
+      current directory (./).
Roman Rakus 7b8ddd
+      local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames
Roman Rakus 7b8ddd
+      in the current directory (e.g., lib/sh).
Roman Rakus 7b8ddd
+      XXX - should we do spelling correction on these? */
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+   /* This is test as it was in bash-4.2: skip relative pathnames in current
Roman Rakus 7b8ddd
+      directory.  Change test to
Roman Rakus 7b8ddd
+       (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/'))
Roman Rakus 7b8ddd
+      if we want to skip paths beginning with ./ also. */
Roman Rakus 7b8ddd
    if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
Roman Rakus 7b8ddd
      {
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2764,2767 ****
Roman Rakus 7b8ddd
--- 2873,2885 ----
Roman Rakus 7b8ddd
        int len1, len2;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+       /* If we have a relative path
Roman Rakus 7b8ddd
+       		(local_dirname[0] != '/' && local_dirname[0] != '.')
Roman Rakus 7b8ddd
+ 	 that is canonical after appending it to the current directory, then
Roman Rakus 7b8ddd
+ 	 	temp1 = temp2+'/'
Roman Rakus 7b8ddd
+ 	 That is,
Roman Rakus 7b8ddd
+ 	 	strcmp (temp1, temp2) == 0
Roman Rakus 7b8ddd
+ 	 after adding a slash to temp2 below.  It should be safe to not
Roman Rakus 7b8ddd
+ 	 change those.
Roman Rakus 7b8ddd
+       */
Roman Rakus 7b8ddd
        t = get_working_directory ("symlink-hook");
Roman Rakus 7b8ddd
        temp1 = make_absolute (local_dirname, t);
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 2798,2802 ****
Roman Rakus 7b8ddd
  	    }
Roman Rakus 7b8ddd
  	}
Roman Rakus 7b8ddd
!       return_value |= STREQ (local_dirname, temp2) == 0;
Roman Rakus 7b8ddd
        free (local_dirname);
Roman Rakus 7b8ddd
        *dirname = temp2;
Roman Rakus 7b8ddd
--- 2916,2928 ----
Roman Rakus 7b8ddd
  	    }
Roman Rakus 7b8ddd
  	}
Roman Rakus 7b8ddd
! 
Roman Rakus 7b8ddd
!       /* dircomplete_expand_relpath == 0 means we want to leave relative
Roman Rakus 7b8ddd
! 	 pathnames that are unchanged by canonicalization alone.
Roman Rakus 7b8ddd
! 	 *local_dirname != '/' && *local_dirname != '.' == relative pathname
Roman Rakus 7b8ddd
! 	 (consistent with general.c:absolute_pathname())
Roman Rakus 7b8ddd
! 	 temp1 == temp2 (after appending a slash to temp2) means the pathname
Roman Rakus 7b8ddd
! 	 is not changed by canonicalization as described above. */
Roman Rakus 7b8ddd
!       if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0))
Roman Rakus 7b8ddd
! 	return_value |= STREQ (local_dirname, temp2) == 0;
Roman Rakus 7b8ddd
        free (local_dirname);
Roman Rakus 7b8ddd
        *dirname = temp2;
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 3003,3012 ****
Roman Rakus 7b8ddd
    orig_func = rl_completion_entry_function;
Roman Rakus 7b8ddd
    orig_attempt_func = rl_attempted_completion_function;
Roman Rakus 7b8ddd
-   orig_dir_func = rl_directory_rewrite_hook;
Roman Rakus 7b8ddd
    orig_ignore_func = rl_ignore_some_completions_function;
Roman Rakus 7b8ddd
    orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
Roman Rakus 7b8ddd
    rl_completion_entry_function = rl_filename_completion_function;
Roman Rakus 7b8ddd
    rl_attempted_completion_function = (rl_completion_func_t *)NULL;
Roman Rakus 7b8ddd
-   rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = filename_completion_ignore;
Roman Rakus 7b8ddd
    rl_completer_word_break_characters = " \t\n\"\'";
Roman Rakus 7b8ddd
--- 3129,3139 ----
Roman Rakus 7b8ddd
    orig_func = rl_completion_entry_function;
Roman Rakus 7b8ddd
    orig_attempt_func = rl_attempted_completion_function;
Roman Rakus 7b8ddd
    orig_ignore_func = rl_ignore_some_completions_function;
Roman Rakus 7b8ddd
    orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
+   orig_dir_func = save_directory_hook ();
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
    rl_completion_entry_function = rl_filename_completion_function;
Roman Rakus 7b8ddd
    rl_attempted_completion_function = (rl_completion_func_t *)NULL;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = filename_completion_ignore;
Roman Rakus 7b8ddd
    rl_completer_word_break_characters = " \t\n\"\'";
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 3016,3023 ****
Roman Rakus 7b8ddd
    rl_completion_entry_function = orig_func;
Roman Rakus 7b8ddd
    rl_attempted_completion_function = orig_attempt_func;
Roman Rakus 7b8ddd
-   rl_directory_rewrite_hook = orig_dir_func;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = orig_ignore_func;
Roman Rakus 7b8ddd
    rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
    return r;
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
--- 3143,3151 ----
Roman Rakus 7b8ddd
    rl_completion_entry_function = orig_func;
Roman Rakus 7b8ddd
    rl_attempted_completion_function = orig_attempt_func;
Roman Rakus 7b8ddd
    rl_ignore_some_completions_function = orig_ignore_func;
Roman Rakus 7b8ddd
    rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+   restore_directory_hook (orig_dir_func);
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
    return r;
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/bashline.h ./bashline.h
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/bashline.h	2009-01-04 14:32:22.000000000 -0500
Roman Rakus 7b8ddd
--- ./bashline.h	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 34,41 ****
Roman Rakus 7b8ddd
--- 34,46 ----
Roman Rakus 7b8ddd
  extern int bash_re_edit __P((char *));
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ extern void bashline_set_event_hook __P((void));
Roman Rakus 7b8ddd
+ extern void bashline_reset_event_hook __P((void));
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  extern int bind_keyseq_to_unix_command __P((char *));
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
  extern char **bash_default_completion __P((const char *, int, int, int, int));
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ void set_directory_hook __P((void));
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  /* Used by programmable completion code. */
Roman Rakus 7b8ddd
  extern char *command_word_completion_function __P((const char *, int));
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/builtins/shopt.def ./builtins/shopt.def
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/builtins/shopt.def	2010-07-02 22:42:44.000000000 -0400
Roman Rakus 7b8ddd
--- ./builtins/shopt.def	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 62,65 ****
Roman Rakus 7b8ddd
--- 62,69 ----
Roman Rakus 7b8ddd
  #include "bashgetopt.h"
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ #if defined (READLINE)
Roman Rakus 7b8ddd
+ #  include "../bashline.h"
Roman Rakus 7b8ddd
+ #endif
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  #if defined (HISTORY)
Roman Rakus 7b8ddd
  #  include "../bashhist.h"
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 95,99 ****
Roman Rakus 7b8ddd
  extern int no_empty_command_completion;
Roman Rakus 7b8ddd
  extern int force_fignore;
Roman Rakus 7b8ddd
! extern int dircomplete_spelling;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
  extern int enable_hostname_completion __P((int));
Roman Rakus 7b8ddd
--- 99,103 ----
Roman Rakus 7b8ddd
  extern int no_empty_command_completion;
Roman Rakus 7b8ddd
  extern int force_fignore;
Roman Rakus 7b8ddd
! extern int dircomplete_spelling, dircomplete_expand;
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
  extern int enable_hostname_completion __P((int));
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 122,125 ****
Roman Rakus 7b8ddd
--- 126,133 ----
Roman Rakus 7b8ddd
  #endif
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ #if defined (READLINE)
Roman Rakus 7b8ddd
+ static int shopt_set_complete_direxpand __P((char *, int));
Roman Rakus 7b8ddd
+ #endif
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  static int shopt_login_shell;
Roman Rakus 7b8ddd
  static int shopt_compat31;
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 151,154 ****
Roman Rakus 7b8ddd
--- 159,163 ----
Roman Rakus 7b8ddd
    { "compat41", &shopt_compat41, set_compatibility_level },
Roman Rakus 7b8ddd
  #if defined (READLINE)
Roman Rakus 7b8ddd
+   { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
Roman Rakus 7b8ddd
    { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
Roman Rakus 7b8ddd
  #endif
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 536,539 ****
Roman Rakus 7b8ddd
--- 545,559 ----
Roman Rakus 7b8ddd
  }
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ #if defined (READLINE)
Roman Rakus 7b8ddd
+ static int
Roman Rakus 7b8ddd
+ shopt_set_complete_direxpand (option_name, mode)
Roman Rakus 7b8ddd
+      char *option_name;
Roman Rakus 7b8ddd
+      int mode;
Roman Rakus 7b8ddd
+ {
Roman Rakus 7b8ddd
+   set_directory_hook ();
Roman Rakus 7b8ddd
+   return 0;
Roman Rakus 7b8ddd
+ }
Roman Rakus 7b8ddd
+ #endif
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  #if defined (RESTRICTED_SHELL)
Roman Rakus 7b8ddd
  /* Don't allow the value of restricted_shell to be modified. */
Roman Rakus 7b8ddd
Binary files ../bash-4.2-patched/doc/._bashref.pdf and ./doc/._bashref.pdf differ
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/doc/bash.1 ./doc/bash.1
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/doc/bash.1	2011-01-16 15:31:39.000000000 -0500
Roman Rakus 7b8ddd
--- ./doc/bash.1	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 8949,8952 ****
Roman Rakus 7b8ddd
--- 8949,8962 ----
Roman Rakus 7b8ddd
  The default bash behavior remains as in previous versions.
Roman Rakus 7b8ddd
  .TP 8
Roman Rakus 7b8ddd
+ .B direxpand
Roman Rakus 7b8ddd
+ If set,
Roman Rakus 7b8ddd
+ .B bash
Roman Rakus 7b8ddd
+ replaces directory names with the results of word expansion when performing
Roman Rakus 7b8ddd
+ filename completion.  This changes the contents of the readline editing
Roman Rakus 7b8ddd
+ buffer.
Roman Rakus 7b8ddd
+ If not set,
Roman Rakus 7b8ddd
+ .B bash
Roman Rakus 7b8ddd
+ attempts to preserve what the user typed.
Roman Rakus 7b8ddd
+ .TP 8
Roman Rakus 7b8ddd
  .B dirspell
Roman Rakus 7b8ddd
  If set,
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/doc/bashref.texi ./doc/bashref.texi
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/doc/bashref.texi	2011-01-16 15:31:57.000000000 -0500
Roman Rakus 7b8ddd
--- ./doc/bashref.texi	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 4536,4539 ****
Roman Rakus 7b8ddd
--- 4536,4546 ----
Roman Rakus 7b8ddd
  The default Bash behavior remains as in previous versions.
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
+ @item direxpand
Roman Rakus 7b8ddd
+ If set, Bash
Roman Rakus 7b8ddd
+ replaces directory names with the results of word expansion when performing
Roman Rakus 7b8ddd
+ filename completion.  This changes the contents of the readline editing
Roman Rakus 7b8ddd
+ buffer.
Roman Rakus 7b8ddd
+ If not set, Bash attempts to preserve what the user typed.
Roman Rakus 7b8ddd
+ 
Roman Rakus 7b8ddd
  @item dirspell
Roman Rakus 7b8ddd
  If set, Bash
Roman Rakus 7b8ddd
diff -NrC 2 ../bash-4.2-patched/tests/shopt.right ./tests/shopt.right
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/tests/shopt.right	2010-07-02 23:36:30.000000000 -0400
Roman Rakus 7b8ddd
--- ./tests/shopt.right	2012-05-07 16:27:18.000000000 -0400
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 13,16 ****
Roman Rakus 7b8ddd
--- 13,17 ----
Roman Rakus 7b8ddd
  shopt -u compat40
Roman Rakus 7b8ddd
  shopt -u compat41
Roman Rakus 7b8ddd
+ shopt -u direxpand
Roman Rakus 7b8ddd
  shopt -u dirspell
Roman Rakus 7b8ddd
  shopt -u dotglob
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 69,72 ****
Roman Rakus 7b8ddd
--- 70,74 ----
Roman Rakus 7b8ddd
  shopt -u compat40
Roman Rakus 7b8ddd
  shopt -u compat41
Roman Rakus 7b8ddd
+ shopt -u direxpand
Roman Rakus 7b8ddd
  shopt -u dirspell
Roman Rakus 7b8ddd
  shopt -u dotglob
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 102,105 ****
Roman Rakus 7b8ddd
--- 104,108 ----
Roman Rakus 7b8ddd
  compat40       	off
Roman Rakus 7b8ddd
  compat41       	off
Roman Rakus 7b8ddd
+ direxpand      	off
Roman Rakus 7b8ddd
  dirspell       	off
Roman Rakus 7b8ddd
  dotglob        	off
Roman Rakus 7b8ddd
*** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
Roman Rakus 7b8ddd
--- patchlevel.h	Thu Feb 24 21:41:34 2011
Roman Rakus 7b8ddd
***************
Roman Rakus 7b8ddd
*** 26,30 ****
Roman Rakus 7b8ddd
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
! #define PATCHLEVEL 28
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus 7b8ddd
--- 26,30 ----
Roman Rakus 7b8ddd
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
! #define PATCHLEVEL 29
Roman Rakus 7b8ddd
  
Roman Rakus 7b8ddd
  #endif /* _PATCHLEVEL_H_ */