source: patches/bash-4.2-branch_update-5.patch@ f1778eba

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since f1778eba was bad4693, checked in by William Harrington <kb0iic@…>, 12 years ago

Add header info to bash-4.2-branch_update-5.patch and vim-7.3-branch_update-5.patch

  • Property mode set to 100644
File size: 52.6 KB
  • assoc.c

    Submitted By: William Harrington (kb0iic at gmail dot com)
    Date: 07-31-2012
    Initial Package Version: 4.2
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 4.2-037
    
    diff -Naur bash-4.2.orig/assoc.c bash-4.2/assoc.c
    old new  
    7777  b = hash_search (key, hash, HASH_CREATE);
    7878  if (b == 0)
    7979    return -1;
     80  /* If we are overwriting an existing element's value, we're not going to
     81     use the key.  Nothing in the array assignment code path frees the key
     82     string, so we can free it here to avoid a memory leak. */
     83  if (b->key != key)
     84    free (key);
    8085  FREE (b->data);
    8186  b->data = value ? savestring (value) : (char *)0;
    8287  return (0);
  • bashline.c

    diff -Naur bash-4.2.orig/bashline.c bash-4.2/bashline.c
    old new  
    121121static int filename_completion_ignore __P((char **));
    122122static int bash_push_line __P((void));
    123123
     124static rl_icppfunc_t *save_directory_hook __P((void));
     125static void reset_directory_hook __P((rl_icppfunc_t *));
     126
    124127static void cleanup_expansion_error __P((void));
    125128static void maybe_make_readline_line __P((char *));
    126129static void set_up_new_line __P((char *));
     
    243246/* Perform spelling correction on directory names during word completion */
    244247int dircomplete_spelling = 0;
    245248
     249/* Expand directory names during word/filename completion. */
     250int dircomplete_expand = 0;
     251int dircomplete_expand_relpath = 0;
     252
    246253static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
    247254static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
    248255/* )) */
    249256
     257static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
     258static char *custom_filename_quote_characters = 0;
     259
    250260static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
    251261
    252262static int dot_in_path = 0;
     
    501511
    502512  /* Tell the completer that we might want to follow symbolic links or
    503513     do other expansion on directory names. */
    504   rl_directory_rewrite_hook = bash_directory_completion_hook;
     514  set_directory_hook ();
    505515
    506516  rl_filename_rewrite_hook = bash_filename_rewrite_hook;
    507517
     
    529539  enable_hostname_completion (perform_hostname_completion);
    530540
    531541  /* characters that need to be quoted when appearing in filenames. */
    532   rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~";       /*}*/
     542  rl_filename_quote_characters = default_filename_quote_characters;
    533543
    534544  rl_filename_quoting_function = bash_quote_filename;
    535545  rl_filename_dequoting_function = bash_dequote_filename;
     
    564574  tilde_initialize ();
    565575  rl_attempted_completion_function = attempt_shell_completion;
    566576  rl_completion_entry_function = NULL;
    567   rl_directory_rewrite_hook = bash_directory_completion_hook;
    568577  rl_ignore_some_completions_function = filename_completion_ignore;
     578  rl_filename_quote_characters = default_filename_quote_characters;
     579
     580  set_directory_hook ();
    569581}
    570582
    571583/* Contains the line to push into readline. */
     
    12791291  matches = (char **)NULL;
    12801292  rl_ignore_some_completions_function = filename_completion_ignore;
    12811293
     1294  rl_filename_quote_characters = default_filename_quote_characters;
     1295  set_directory_hook ();
     1296
    12821297  /* Determine if this could be a command word.  It is if it appears at
    12831298     the start of the line (ignoring preceding whitespace), or if it
    12841299     appears after a character that separates commands.  It cannot be a
     
    15911606            }
    15921607          else
    15931608            {
     1609             if (dircomplete_expand && dot_or_dotdot (filename_hint))
     1610                {
     1611                  dircomplete_expand = 0;
     1612                  set_directory_hook ();
     1613                  dircomplete_expand = 1;
     1614                }
    15941615              mapping_over = 4;
    15951616              goto inner;
    15961617            }
     
    17911812
    17921813 inner:
    17931814  val = rl_filename_completion_function (filename_hint, istate);
     1815  if (mapping_over == 4 && dircomplete_expand)
     1816    set_directory_hook ();
     1817
    17941818  istate = 1;
    17951819
    17961820  if (val == 0)
     
    26932717  return conv;
    26942718}
    26952719
     2720/* Functions to save and restore the appropriate directory hook */
     2721/* This is not static so the shopt code can call it */
     2722void
     2723set_directory_hook ()
     2724{
     2725  if (dircomplete_expand)
     2726    {
     2727      rl_directory_completion_hook = bash_directory_completion_hook;
     2728      rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
     2729    }
     2730  else
     2731    {
     2732      rl_directory_rewrite_hook = bash_directory_completion_hook;
     2733      rl_directory_completion_hook = (rl_icppfunc_t *)0;
     2734    }
     2735}
     2736
     2737static rl_icppfunc_t *
     2738save_directory_hook ()
     2739{
     2740  rl_icppfunc_t *ret;
     2741
     2742  if (dircomplete_expand)
     2743    {
     2744      ret = rl_directory_completion_hook;
     2745      rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
     2746    }
     2747  else
     2748    {
     2749      ret = rl_directory_rewrite_hook;
     2750      rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
     2751    }
     2752
     2753  return ret;
     2754}
     2755
     2756static void
     2757restore_directory_hook (hookf)
     2758     rl_icppfunc_t *hookf;
     2759{
     2760  if (dircomplete_expand)
     2761    rl_directory_completion_hook = hookf;
     2762  else
     2763    rl_directory_rewrite_hook = hookf;
     2764}
     2765
    26962766/* Handle symbolic link references and other directory name
    26972767   expansions while hacking completion.  This should return 1 if it modifies
    26982768   the DIRNAME argument, 0 otherwise.  It should make sure not to modify
     
    27022772     char **dirname;
    27032773{
    27042774  char *local_dirname, *new_dirname, *t;
    2705   int return_value, should_expand_dirname;
     2775  int return_value, should_expand_dirname, nextch, closer;
    27062776  WORD_LIST *wl;
    27072777  struct stat sb;
    27082778
    2709   return_value = should_expand_dirname = 0;
     2779  return_value = should_expand_dirname = nextch = closer = 0;
    27102780  local_dirname = *dirname;
    27112781
    2712   if (mbschr (local_dirname, '$'))
    2713     should_expand_dirname = 1;
     2782  if (t = mbschr (local_dirname, '$'))
     2783    {
     2784      should_expand_dirname = '$';
     2785      nextch = t[1];
     2786      /* Deliberately does not handle the deprecated $[...] arithmetic
     2787         expansion syntax */
     2788      if (nextch == '(')
     2789        closer = ')';
     2790      else if (nextch == '{')
     2791        closer = '}';
     2792      else
     2793        nextch = 0;
     2794    }
    27142795  else
    27152796    {
    27162797      t = mbschr (local_dirname, '`');
    27172798      if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
    2718         should_expand_dirname = 1;
     2799        should_expand_dirname = '`';
    27192800    }
    27202801
    27212802#if defined (HAVE_LSTAT)
     
    27392820          free (new_dirname);
    27402821          dispose_words (wl);
    27412822          local_dirname = *dirname;
     2823          /* XXX - change rl_filename_quote_characters here based on
     2824             should_expand_dirname/nextch/closer.  This is the only place
     2825             custom_filename_quote_characters is modified. */
     2826          if (rl_filename_quote_characters && *rl_filename_quote_characters)
     2827            {
     2828              int i, j, c;
     2829              i = strlen (default_filename_quote_characters);
     2830              custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
     2831              for (i = j = 0; c = default_filename_quote_characters[i]; i++)
     2832                {
     2833                  if (c == should_expand_dirname || c == nextch || c == closer)
     2834                    continue;
     2835                  custom_filename_quote_characters[j++] = c;
     2836                }
     2837              custom_filename_quote_characters[j] = '\0';
     2838              rl_filename_quote_characters = custom_filename_quote_characters;
     2839            }
    27422840        }
    27432841      else
    27442842        {
     
    27582856      local_dirname = *dirname = new_dirname;
    27592857    }
    27602858
     2859  /* no_symbolic_links == 0 -> use (default) logical view of the file system.
     2860     local_dirname[0] == '.' && local_dirname[1] == '/' means files in the
     2861     current directory (./).
     2862     local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames
     2863     in the current directory (e.g., lib/sh).
     2864     XXX - should we do spelling correction on these? */
     2865
     2866  /* This is test as it was in bash-4.2: skip relative pathnames in current
     2867     directory.  Change test to
     2868      (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/'))
     2869     if we want to skip paths beginning with ./ also. */
    27612870  if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
    27622871    {
    27632872      char *temp1, *temp2;
    27642873      int len1, len2;
    27652874
     2875      /* If we have a relative path
     2876                (local_dirname[0] != '/' && local_dirname[0] != '.')
     2877         that is canonical after appending it to the current directory, then
     2878                temp1 = temp2+'/'
     2879         That is,
     2880                strcmp (temp1, temp2) == 0
     2881         after adding a slash to temp2 below.  It should be safe to not
     2882         change those.
     2883      */
    27662884      t = get_working_directory ("symlink-hook");
    27672885      temp1 = make_absolute (local_dirname, t);
    27682886      free (t);
     
    27972915              temp2[len2 + 1] = '\0';
    27982916            }
    27992917        }
    2800       return_value |= STREQ (local_dirname, temp2) == 0;
     2918
     2919      /* dircomplete_expand_relpath == 0 means we want to leave relative
     2920         pathnames that are unchanged by canonicalization alone.
     2921         *local_dirname != '/' && *local_dirname != '.' == relative pathname
     2922         (consistent with general.c:absolute_pathname())
     2923         temp1 == temp2 (after appending a slash to temp2) means the pathname
     2924         is not changed by canonicalization as described above. */
     2925      if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0))
     2926        return_value |= STREQ (local_dirname, temp2) == 0;
    28012927      free (local_dirname);
    28022928      *dirname = temp2;
    28032929      free (temp1);
     
    30023128
    30033129  orig_func = rl_completion_entry_function;
    30043130  orig_attempt_func = rl_attempted_completion_function;
    3005   orig_dir_func = rl_directory_rewrite_hook;
    30063131  orig_ignore_func = rl_ignore_some_completions_function;
    30073132  orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
     3133
     3134  orig_dir_func = save_directory_hook ();
     3135
    30083136  rl_completion_entry_function = rl_filename_completion_function;
    30093137  rl_attempted_completion_function = (rl_completion_func_t *)NULL;
    3010   rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
    30113138  rl_ignore_some_completions_function = filename_completion_ignore;
    30123139  rl_completer_word_break_characters = " \t\n\"\'";
    30133140
     
    30153142
    30163143  rl_completion_entry_function = orig_func;
    30173144  rl_attempted_completion_function = orig_attempt_func;
    3018   rl_directory_rewrite_hook = orig_dir_func;
    30193145  rl_ignore_some_completions_function = orig_ignore_func;
    30203146  rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
    30213147
     3148  restore_directory_hook (orig_dir_func);
     3149
    30223150  return r;
    30233151}
    30243152
  • bashline.h

    diff -Naur bash-4.2.orig/bashline.h bash-4.2/bashline.h
    old new  
    3333extern void bashline_reinitialize __P((void));
    3434extern int bash_re_edit __P((char *));
    3535
     36extern void bashline_set_event_hook __P((void));
     37extern void bashline_reset_event_hook __P((void));
     38
    3639extern int bind_keyseq_to_unix_command __P((char *));
    3740
    3841extern char **bash_default_completion __P((const char *, int, int, int, int));
    3942
     43void set_directory_hook __P((void));
     44
    4045/* Used by programmable completion code. */
    4146extern char *command_word_completion_function __P((const char *, int));
    4247extern char *bash_groupname_completion_function __P((const char *, int));
  • builtins/declare.def

    diff -Naur bash-4.2.orig/builtins/declare.def bash-4.2/builtins/declare.def
    old new  
    513513              *subscript_start = '[';   /* ] */
    514514              var = assign_array_element (name, value, 0);      /* XXX - not aflags */
    515515              *subscript_start = '\0';
     516              if (var == 0)     /* some kind of assignment error */
     517                {
     518                  assign_error++;
     519                  NEXT_VARIABLE ();
     520                }
    516521            }
    517522          else if (simple_array_assign)
    518523            {
  • builtins/fc.def

    diff -Naur bash-4.2.orig/builtins/fc.def bash-4.2/builtins/fc.def
    old new  
    304304  last_hist = i - rh - hist_last_line_added;
    305305
    306306  /* XXX */
    307   if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
     307  if (i == last_hist && hlist[last_hist] == 0)
    308308    while (last_hist >= 0 && hlist[last_hist] == 0)
    309309      last_hist--;
    310310  if (last_hist < 0)
     
    475475     HIST_ENTRY **hlist;
    476476{
    477477  int sign, n, clen, rh;
    478   register int i, j;
     478  register int i, j, last_hist;
    479479  register char *s;
    480480
    481481  sign = 1;
     
    495495     has been enabled (interactive or not) should use it in the last_hist
    496496     calculation as if it were on. */
    497497  rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
    498   i -= rh + hist_last_line_added;
     498  last_hist = i - rh - hist_last_line_added;
     499
     500  if (i == last_hist && hlist[last_hist] == 0)
     501    while (last_hist >= 0 && hlist[last_hist] == 0)
     502      last_hist--;
     503  if (last_hist < 0)
     504    return (-1);
     505
     506  i = last_hist;
    499507
    500508  /* No specification defaults to most recent command. */
    501509  if (command == NULL)
  • builtins/mapfile.def

    diff -Naur bash-4.2.orig/builtins/mapfile.def bash-4.2/builtins/mapfile.def
    old new  
    195195  /* Reset the buffer for bash own stream */
    196196  interrupt_immediately++;
    197197  for (array_index = origin, line_count = 1;
    198        zgetline (fd, &line, &line_length, unbuffered_read) != -1;
    199        array_index++, line_count++)
     198        zgetline (fd, &line, &line_length, unbuffered_read) != -1;
     199        array_index++)
    200200    {
    201       /* Have we exceeded # of lines to store? */
    202       if (line_count_goal != 0 && line_count > line_count_goal)
    203         break;
    204 
    205201      /* Remove trailing newlines? */
    206202      if (flags & MAPF_CHOP)
    207203        do_chop (line);
     
    217213        }
    218214
    219215      bind_array_element (entry, array_index, line, 0);
     216
     217      /* Have we exceeded # of lines to store? */
     218      line_count++;
     219      if (line_count_goal != 0 && line_count > line_count_goal)
     220        break;
    220221    }
    221222
    222223  xfree (line);
  • builtins/printf.def

    diff -Naur bash-4.2.orig/builtins/printf.def bash-4.2/builtins/printf.def
    old new  
    255255#endif
    256256            {
    257257              vflag = 1;
     258              if (vbsize == 0)
     259                vbuf = xmalloc (vbsize = 16);
    258260              vblen = 0;
    259261              if (vbuf)
    260262                vbuf[0] = 0;
     
    465467                  secs = shell_start_time;      /* roughly $SECONDS */
    466468                else
    467469                  secs = arg;
     470#if defined (HAVE_TZSET)
     471                sv_tz ("TZ");           /* XXX -- just make sure */
     472#endif
    468473                tm = localtime (&secs);
    469474                n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
    470475                free (timefmt);
  • builtins/read.def

    diff -Naur bash-4.2.orig/builtins/read.def bash-4.2/builtins/read.def
    old new  
    642642          xfree (input_string);
    643643          return EXECUTION_FAILURE;     /* readonly or noassign */
    644644        }
     645      if (assoc_p (var))
     646        {
     647          builtin_error (_("%s: cannot convert associative to indexed array"), arrayname);
     648          xfree (input_string);
     649          return EXECUTION_FAILURE;     /* existing associative array */
     650        }
    645651      array_flush (array_cell (var));
    646652
    647653      alist = list_string (input_string, ifs_chars, 0);
     
    731737              xfree (t1);
    732738            }
    733739          else
    734             var = bind_read_variable (varname, t);
     740            var = bind_read_variable (varname, t ? t : "");
    735741        }
    736742      else
    737743        {
     
    792798      xfree (t);
    793799    }
    794800  else
    795     var = bind_read_variable (list->word->word, input_string);
     801    var = bind_read_variable (list->word->word, input_string ? input_string : "");
    796802
    797803  if (var)
    798804    {
  • builtins/shopt.def

    diff -Naur bash-4.2.orig/builtins/shopt.def bash-4.2/builtins/shopt.def
    old new  
    6161#include "common.h"
    6262#include "bashgetopt.h"
    6363
     64#if defined (READLINE)
     65#  include "../bashline.h"
     66#endif
     67
    6468#if defined (HISTORY)
    6569#  include "../bashhist.h"
    6670#endif
     
    9498extern int hist_verify, history_reediting, perform_hostname_completion;
    9599extern int no_empty_command_completion;
    96100extern int force_fignore;
    97 extern int dircomplete_spelling;
     101extern int dircomplete_spelling, dircomplete_expand;
    98102
    99103extern int enable_hostname_completion __P((int));
    100104#endif
     
    121125static int set_restricted_shell __P((char *, int));
    122126#endif
    123127
     128#if defined (READLINE)
     129static int shopt_set_complete_direxpand __P((char *, int));
     130#endif
     131
    124132static int shopt_login_shell;
    125133static int shopt_compat31;
    126134static int shopt_compat32;
     
    150158  { "compat40", &shopt_compat40, set_compatibility_level },
    151159  { "compat41", &shopt_compat41, set_compatibility_level },
    152160#if defined (READLINE)
     161  { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
    153162  { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
    154163#endif
    155164  { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
     
    535544  return 0;
    536545}
    537546
     547#if defined (READLINE)
     548static int
     549shopt_set_complete_direxpand (option_name, mode)
     550     char *option_name;
     551     int mode;
     552{
     553  set_directory_hook ();
     554  return 0;
     555}
     556#endif
     557
    538558#if defined (RESTRICTED_SHELL)
    539559/* Don't allow the value of restricted_shell to be modified. */
    540560
  • command.h

    diff -Naur bash-4.2.orig/command.h bash-4.2/command.h
    old new  
    9797#define W_HASCTLESC     0x200000        /* word contains literal CTLESC characters */
    9898#define W_ASSIGNASSOC   0x400000        /* word looks like associative array assignment */
    9999#define W_ARRAYIND      0x800000        /* word is an array index being expanded */
     100#define W_ASSNGLOBAL    0x1000000       /* word is a global assignment to declare (declare/typeset -g) */
    100101
    101102/* Possible values for subshell_environment */
    102103#define SUBSHELL_ASYNC  0x01    /* subshell caused by `command &' */
  • doc/bash.1

    diff -Naur bash-4.2.orig/doc/bash.1 bash-4.2/doc/bash.1
    old new  
    89488948quoted.  This is the behavior of posix mode through version 4.1.
    89498949The default bash behavior remains as in previous versions.
    89508950.TP 8
     8951.B direxpand
     8952If set,
     8953.B bash
     8954replaces directory names with the results of word expansion when performing
     8955filename completion.  This changes the contents of the readline editing
     8956buffer.
     8957If not set,
     8958.B bash
     8959attempts to preserve what the user typed.
     8960.TP 8
    89518961.B dirspell
    89528962If set,
    89538963.B bash
  • doc/bashref.texi

    diff -Naur bash-4.2.orig/doc/bashref.texi bash-4.2/doc/bashref.texi
    old new  
    45354535quoted.  This is the behavior of @sc{posix} mode through version 4.1.
    45364536The default Bash behavior remains as in previous versions.
    45374537
     4538@item direxpand
     4539If set, Bash
     4540replaces directory names with the results of word expansion when performing
     4541filename completion.  This changes the contents of the readline editing
     4542buffer.
     4543If not set, Bash attempts to preserve what the user typed.
     4544
    45384545@item dirspell
    45394546If set, Bash
    45404547attempts spelling correction on directory names during word completion
  • error.c

    diff -Naur bash-4.2.orig/error.c bash-4.2/error.c
    old new  
    200200
    201201  va_end (args);
    202202  if (exit_immediately_on_error)
    203     exit_shell (1);
     203    {
     204      if (last_command_exit_value == 0)
     205        last_command_exit_value = 1;
     206      exit_shell (last_command_exit_value);
     207    }
    204208}
    205209
    206210void
  • execute_cmd.c

    diff -Naur bash-4.2.orig/execute_cmd.c bash-4.2/execute_cmd.c
    old new  
    21962196  if (ignore_return && cmd)
    21972197    cmd->flags |= CMD_IGNORE_RETURN;
    21982198
     2199#if defined (JOB_CONTROL)
    21992200  lastpipe_flag = 0;
    22002201  begin_unwind_frame ("lastpipe-exec");
    22012202  lstdin = -1;
     
    22042205     current shell environment. */
    22052206  if (lastpipe_opt && job_control == 0 && asynchronous == 0 && pipe_out == NO_PIPE && prev > 0)
    22062207    {
    2207       lstdin = move_to_high_fd (0, 0, 255);
     2208      lstdin = move_to_high_fd (0, 1, -1);
    22082209      if (lstdin > 0)
    22092210        {
    22102211          do_piping (prev, pipe_out);
     
    22152216          lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL);    /* XXX */
    22162217          add_unwind_protect (lastpipe_cleanup, lastpipe_jid);
    22172218        }
    2218       cmd->flags |= CMD_LASTPIPE;
     2219      if (cmd)
     2220        cmd->flags |= CMD_LASTPIPE;
    22192221    }     
    22202222  if (prev >= 0)
    22212223    add_unwind_protect (close, prev);
     2224#endif
    22222225
    22232226  exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close);
    22242227
     2228#if defined (JOB_CONTROL)
    22252229  if (lstdin > 0)
    22262230    restore_stdin (lstdin);
     2231#endif
    22272232
    22282233  if (prev >= 0)
    22292234    close (prev);
     
    22462251      unfreeze_jobs_list ();
    22472252    }
    22482253
     2254#if defined (JOB_CONTROL)
    22492255  discard_unwind_frame ("lastpipe-exec");
     2256#endif
    22502257
    22512258  return (exec_result);
    22522259}
     
    35753582{
    35763583  WORD_LIST *w;
    35773584  struct builtin *b;
    3578   int assoc;
     3585  int assoc, global;
    35793586
    35803587  if (words == 0)
    35813588    return;
    35823589
    35833590  b = 0;
    3584   assoc = 0;
     3591  assoc = global = 0;
    35853592
    35863593  for (w = words; w; w = w->next)
    35873594    if (w->word->flags & W_ASSIGNMENT)
     
    35983605#if defined (ARRAY_VARS)
    35993606        if (assoc)
    36003607          w->word->flags |= W_ASSIGNASSOC;
     3608        if (global)
     3609          w->word->flags |= W_ASSNGLOBAL;
    36013610#endif
    36023611      }
    36033612#if defined (ARRAY_VARS)
    36043613    /* Note that we saw an associative array option to a builtin that takes
    36053614       assignment statements.  This is a bit of a kludge. */
    3606     else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
     3615    else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
     3616#else
     3617    else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
     3618#endif
    36073619      {
    36083620        if (b == 0)
    36093621          {
     
    36133625            else if (b && (b->flags & ASSIGNMENT_BUILTIN))
    36143626              words->word->flags |= W_ASSNBLTIN;
    36153627          }
    3616         if (words->word->flags & W_ASSNBLTIN)
     3628        if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
    36173629          assoc = 1;
     3630        if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
     3631          global = 1;
    36183632      }
    3619 #endif
    36203633}
    36213634
    36223635/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
  • bash-4.2

    diff -Naur bash-4.2.orig/expr.c bash-4.2/expr.c
    old new  
    476476
    477477      if (special)
    478478        {
     479          if ((op == DIV || op == MOD) && value == 0)
     480            {
     481              if (noeval == 0)
     482                evalerror (_("division by 0"));
     483              else
     484                value = 1;
     485            }
     486
    479487          switch (op)
    480488            {
    481489            case MUL:
    482490              lvalue *= value;
    483491              break;
    484492            case DIV:
    485               if (value == 0)
    486                 evalerror (_("division by 0"));
    487493              lvalue /= value;
    488494              break;
    489495            case MOD:
    490               if (value == 0)
    491                 evalerror (_("division by 0"));
    492496              lvalue %= value;
    493497              break;
    494498            case PLUS:
     
    804808      val2 = exppower ();
    805809
    806810      if (((op == DIV) || (op == MOD)) && (val2 == 0))
    807         evalerror (_("division by 0"));
     811        {
     812          if (noeval == 0)
     813            evalerror (_("division by 0"));
     814          else
     815            val2 = 1;
     816        }
    808817
    809818      if (op == MUL)
    810819        val1 *= val2;
  • lib/glob/glob.c

    diff -Naur bash-4.2.orig/lib/glob/glob.c bash-4.2/lib/glob/glob.c
    old new  
    200200  wchar_t *pat_wc, *dn_wc;
    201201  size_t pat_n, dn_n;
    202202
     203  pat_wc = dn_wc = (wchar_t *)NULL;
     204
    203205  pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
    204   dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
     206  if (pat_n != (size_t)-1)
     207    dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
    205208
    206209  ret = 0;
    207210  if (pat_n != (size_t)-1 && dn_n !=(size_t)-1)
     
    221224           (pat_wc[0] != L'\\' || pat_wc[1] != L'.'))
    222225        ret = 1;
    223226    }
     227  else
     228    ret = skipname (pat, dname, flags);
    224229
    225230  FREE (pat_wc);
    226231  FREE (dn_wc);
     
    266271  /* Convert the strings into wide characters.  */
    267272  n = xdupmbstowcs (&wpathname, NULL, pathname);
    268273  if (n == (size_t) -1)
    269     /* Something wrong. */
    270     return;
     274    {
     275      /* Something wrong.  Fall back to single-byte */
     276      udequote_pathname (pathname);
     277      return;
     278    }
    271279  orig_wpathname = wpathname;
    272280
    273281  for (i = j = 0; wpathname && wpathname[i]; )
  • lib/glob/gmisc.c

    diff -Naur bash-4.2.orig/lib/glob/gmisc.c bash-4.2/lib/glob/gmisc.c
    old new  
    7777     wchar_t *wpat;
    7878     size_t wmax;
    7979{
    80   wchar_t wc, *wbrack;
    81   int matlen, t, in_cclass, in_collsym, in_equiv;
     80  wchar_t wc;
     81  int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
    8282
    8383  if (*wpat == 0)
    8484    return (0);
     
    118118          break;
    119119        case L'[':
    120120          /* scan for ending `]', skipping over embedded [:...:] */
    121           wbrack = wpat;
     121          bracklen = 1;
    122122          wc = *wpat++;
    123123          do
    124124            {
    125125              if (wc == 0)
    126126                {
    127                   matlen += wpat - wbrack - 1;  /* incremented below */
    128                   break;
     127                  wpat--;                       /* back up to NUL */
     128                  matlen += bracklen;
     129                  goto bad_bracket;
    129130                }
    130131              else if (wc == L'\\')
    131132                {
    132                   wc = *wpat++;
    133                   if (*wpat == 0)
    134                     break;
     133                  /* *wpat == backslash-escaped character */
     134                  bracklen++;
     135                  /* If the backslash or backslash-escape ends the string,
     136                     bail.  The ++wpat skips over the backslash escape */
     137                  if (*wpat == 0 || *++wpat == 0)
     138                    {
     139                      matlen += bracklen;
     140                      goto bad_bracket;
     141                    }
    135142                }
    136143              else if (wc == L'[' && *wpat == L':')     /* character class */
    137144                {
    138145                  wpat++;
     146                  bracklen++;
    139147                  in_cclass = 1;
    140148                }
    141149              else if (in_cclass && wc == L':' && *wpat == L']')
    142150                {
    143151                  wpat++;
     152                  bracklen++;
    144153                  in_cclass = 0;
    145154                }
    146155              else if (wc == L'[' && *wpat == L'.')     /* collating symbol */
    147156                {
    148157                  wpat++;
     158                  bracklen++;
    149159                  if (*wpat == L']')    /* right bracket can appear as collating symbol */
    150                     wpat++;
     160                    {
     161                      wpat++;
     162                      bracklen++;
     163                    }
    151164                  in_collsym = 1;
    152165                }
    153166              else if (in_collsym && wc == L'.' && *wpat == L']')
    154167                {
    155168                  wpat++;
     169                  bracklen++;
    156170                  in_collsym = 0;
    157171                }
    158172              else if (wc == L'[' && *wpat == L'=')     /* equivalence class */
    159173                {
    160174                  wpat++;
     175                  bracklen++;
    161176                  if (*wpat == L']')    /* right bracket can appear as equivalence class */
    162                     wpat++;
     177                    {
     178                      wpat++;
     179                      bracklen++;
     180                    }
    163181                  in_equiv = 1;
    164182                }
    165183              else if (in_equiv && wc == L'=' && *wpat == L']')
    166184                {
    167185                  wpat++;
     186                  bracklen++;
    168187                  in_equiv = 0;
    169188                }
     189              else
     190                bracklen++;
    170191            }
    171192          while ((wc = *wpat++) != L']');
    172193          matlen++;             /* bracket expression can only match one char */
     194bad_bracket:
    173195          break;
    174196        }
    175197    }
     
    213235     char *pat;
    214236     size_t max;
    215237{
    216   char c, *brack;
    217   int matlen, t, in_cclass, in_collsym, in_equiv;
     238  char c;
     239  int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
    218240
    219241  if (*pat == 0)
    220242    return (0);
     
    254276          break;
    255277        case '[':
    256278          /* scan for ending `]', skipping over embedded [:...:] */
    257           brack = pat;
     279          bracklen = 1;
    258280          c = *pat++;
    259281          do
    260282            {
    261283              if (c == 0)
    262284                {
    263                   matlen += pat - brack - 1;    /* incremented below */
    264                   break;
     285                  pat--;                        /* back up to NUL */
     286                  matlen += bracklen;
     287                  goto bad_bracket;
    265288                }
    266289              else if (c == '\\')
    267290                {
    268                   c = *pat++;
    269                   if (*pat == 0)
    270                     break;
     291                  /* *pat == backslash-escaped character */
     292                  bracklen++;
     293                  /* If the backslash or backslash-escape ends the string,
     294                     bail.  The ++pat skips over the backslash escape */
     295                  if (*pat == 0 || *++pat == 0)
     296                    {
     297                      matlen += bracklen;
     298                      goto bad_bracket;
     299                    }
    271300                }
    272301              else if (c == '[' && *pat == ':') /* character class */
    273302                {
    274303                  pat++;
     304                  bracklen++;
    275305                  in_cclass = 1;
    276306                }
    277307              else if (in_cclass && c == ':' && *pat == ']')
    278308                {
    279309                  pat++;
     310                  bracklen++;
    280311                  in_cclass = 0;
    281312                }
    282313              else if (c == '[' && *pat == '.') /* collating symbol */
    283314                {
    284315                  pat++;
     316                  bracklen++;
    285317                  if (*pat == ']')      /* right bracket can appear as collating symbol */
    286                     pat++;
     318                    {
     319                      pat++;
     320                      bracklen++;
     321                    }
    287322                  in_collsym = 1;
    288323                }
    289324              else if (in_collsym && c == '.' && *pat == ']')
    290325                {
    291326                  pat++;
     327                  bracklen++;
    292328                  in_collsym = 0;
    293329                }
    294330              else if (c == '[' && *pat == '=') /* equivalence class */
    295331                {
    296332                  pat++;
     333                  bracklen++;
    297334                  if (*pat == ']')      /* right bracket can appear as equivalence class */
    298                     pat++;
     335                    {
     336                      pat++;
     337                      bracklen++;
     338                    }
    299339                  in_equiv = 1;
    300340                }
    301341              else if (in_equiv && c == '=' && *pat == ']')
    302342                {
    303343                  pat++;
     344                  bracklen++;
    304345                  in_equiv = 0;
    305346                }
     347              else
     348                bracklen++;
    306349            }
    307350          while ((c = *pat++) != ']');
    308351          matlen++;             /* bracket expression can only match one char */
     352bad_bracket:
    309353          break;
    310354        }
    311355    }
  • lib/glob/xmbsrtowcs.c

    diff -Naur bash-4.2.orig/lib/glob/xmbsrtowcs.c bash-4.2/lib/glob/xmbsrtowcs.c
    old new  
    3535
    3636#if HANDLE_MULTIBYTE
    3737
     38#define WSBUF_INC 32
     39
    3840#ifndef FREE
    3941#  define FREE(x)       do { if (x) free (x); } while (0)
    4042#endif
     
    148150  size_t wsbuf_size;    /* Size of WSBUF */
    149151  size_t wcnum;         /* Number of wide characters in WSBUF */
    150152  mbstate_t state;      /* Conversion State */
    151   size_t wcslength;     /* Number of wide characters produced by the conversion. */
     153  size_t n, wcslength;  /* Number of wide characters produced by the conversion. */
    152154  const char *end_or_backslash;
    153155  size_t nms;   /* Number of multibyte characters to convert at one time. */
    154156  mbstate_t tmp_state;
     
    171173      /* Compute the number of produced wide-characters. */
    172174      tmp_p = p;
    173175      tmp_state = state;
    174       wcslength = mbsnrtowcs(NULL, &tmp_p, nms, 0, &tmp_state);
     176
     177      if (nms == 0 && *p == '\\')       /* special initial case */
     178        nms = wcslength = 1;
     179      else
     180        wcslength = mbsnrtowcs (NULL, &tmp_p, nms, 0, &tmp_state);
     181
     182      if (wcslength == 0)
     183        {
     184          tmp_p = p;            /* will need below */
     185          tmp_state = state;
     186          wcslength = 1;        /* take a single byte */
     187        }
    175188
    176189      /* Conversion failed. */
    177190      if (wcslength == (size_t)-1)
     
    186199        {
    187200          wchar_t *wstmp;
    188201
    189           wsbuf_size = wcnum+wcslength+1;       /* 1 for the L'\0' or the potential L'\\' */
     202          while (wsbuf_size < wcnum+wcslength+1) /* 1 for the L'\0' or the potential L'\\' */
     203            wsbuf_size += WSBUF_INC;
    190204
    191205          wstmp = (wchar_t *) realloc (wsbuf, wsbuf_size * sizeof (wchar_t));
    192206          if (wstmp == NULL)
     
    199213        }
    200214
    201215      /* Perform the conversion. This is assumed to return 'wcslength'.
    202        * It may set 'p' to NULL. */
    203       mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
     216        It may set 'p' to NULL. */
     217      n = mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
    204218
    205       wcnum += wcslength;
     219      /* Compensate for taking single byte on wcs conversion failure above. */
     220      if (wcslength == 1 && (n == 0 || n == (size_t)-1))
     221        {
     222          state = tmp_state;
     223          p = tmp_p;
     224          wsbuf[wcnum++] = *p++;
     225        }
     226      else
     227        wcnum += wcslength;
    206228
    207229      if (mbsinit (&state) && (p != NULL) && (*p == '\\'))
    208230        {
     
    230252   If conversion is failed, the return value is (size_t)-1 and the values
    231253   of DESTP and INDICESP are NULL. */
    232254
    233 #define WSBUF_INC 32
    234 
    235255size_t
    236256xdupmbstowcs (destp, indicesp, src)
    237257    wchar_t **destp;    /* Store the pointer to the wide character string */
  • lib/readline/callback.c

    diff -Naur bash-4.2.orig/lib/readline/callback.c bash-4.2/lib/readline/callback.c
    old new  
    148148          eof = _rl_vi_domove_callback (_rl_vimvcxt);
    149149          /* Should handle everything, including cleanup, numeric arguments,
    150150             and turning off RL_STATE_VIMOTION */
     151          if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
     152            _rl_internal_char_cleanup ();
     153
    151154          return;
    152155        }
    153156#endif
  • lib/readline/input.c

    diff -Naur bash-4.2.orig/lib/readline/input.c bash-4.2/lib/readline/input.c
    old new  
    409409int
    410410rl_read_key ()
    411411{
    412   int c;
     412  int c, r;
    413413
    414414  rl_key_sequence_length++;
    415415
     
    429429        {
    430430          while (rl_event_hook)
    431431            {
    432               if (rl_gather_tyi () < 0) /* XXX - EIO */
     432              if (rl_get_char (&c) != 0)
     433                break;
     434               
     435              if ((r = rl_gather_tyi ()) < 0)   /* XXX - EIO */
    433436                {
    434437                  rl_done = 1;
    435438                  return ('\n');
    436439                }
     440              else if (r == 1)                  /* read something */
     441                continue;
     442
    437443              RL_CHECK_SIGNALS ();
    438               if (rl_get_char (&c) != 0)
    439                 break;
    440444              if (rl_done)              /* XXX - experimental */
    441445                return ('\n');
    442446              (*rl_event_hook) ();
  • lib/readline/vi_mode.c

    diff -Naur bash-4.2.orig/lib/readline/vi_mode.c bash-4.2/lib/readline/vi_mode.c
    old new  
    11141114      rl_beg_of_line (1, c);
    11151115      _rl_vi_last_motion = c;
    11161116      RL_UNSETSTATE (RL_STATE_VIMOTION);
    1117       return (0);
     1117      return (vidomove_dispatch (m));
    11181118    }
    11191119#if defined (READLINE_CALLBACKS)
    11201120  /* XXX - these need to handle rl_universal_argument bindings */
     
    12341234      _rl_vimvcxt->motion = '$';
    12351235      r = rl_domove_motion_callback (_rl_vimvcxt);
    12361236    }
    1237   else if (vi_redoing)
     1237  else if (vi_redoing && _rl_vi_last_motion != 'd')     /* `dd' is special */
    12381238    {
    12391239      _rl_vimvcxt->motion = _rl_vi_last_motion;
    12401240      r = rl_domove_motion_callback (_rl_vimvcxt);
    12411241    }
     1242  else if (vi_redoing)          /* handle redoing `dd' here */
     1243    {
     1244      _rl_vimvcxt->motion = _rl_vi_last_motion;
     1245      rl_mark = rl_end;
     1246      rl_beg_of_line (1, key);
     1247      RL_UNSETSTATE (RL_STATE_VIMOTION);
     1248      r = vidomove_dispatch (_rl_vimvcxt);
     1249    }
    12421250#if defined (READLINE_CALLBACKS)
    12431251  else if (RL_ISSTATE (RL_STATE_CALLBACK))
    12441252    {
     
    13161324      _rl_vimvcxt->motion = '$';
    13171325      r = rl_domove_motion_callback (_rl_vimvcxt);
    13181326    }
    1319   else if (vi_redoing)
     1327  else if (vi_redoing && _rl_vi_last_motion != 'c')     /* `cc' is special */
    13201328    {
    13211329      _rl_vimvcxt->motion = _rl_vi_last_motion;
    13221330      r = rl_domove_motion_callback (_rl_vimvcxt);
    13231331    }
     1332  else if (vi_redoing)          /* handle redoing `cc' here */
     1333    {
     1334      _rl_vimvcxt->motion = _rl_vi_last_motion;
     1335      rl_mark = rl_end;
     1336      rl_beg_of_line (1, key);
     1337      RL_UNSETSTATE (RL_STATE_VIMOTION);
     1338      r = vidomove_dispatch (_rl_vimvcxt);
     1339    }
    13241340#if defined (READLINE_CALLBACKS)
    13251341  else if (RL_ISSTATE (RL_STATE_CALLBACK))
    13261342    {
     
    13771393      _rl_vimvcxt->motion = '$';
    13781394      r = rl_domove_motion_callback (_rl_vimvcxt);
    13791395    }
     1396  else if (vi_redoing && _rl_vi_last_motion != 'y')     /* `yy' is special */
     1397    {
     1398      _rl_vimvcxt->motion = _rl_vi_last_motion;
     1399      r = rl_domove_motion_callback (_rl_vimvcxt);
     1400    }
     1401  else if (vi_redoing)                  /* handle redoing `yy' here */
     1402    {
     1403      _rl_vimvcxt->motion = _rl_vi_last_motion;
     1404      rl_mark = rl_end;
     1405      rl_beg_of_line (1, key);
     1406      RL_UNSETSTATE (RL_STATE_VIMOTION);
     1407      r = vidomove_dispatch (_rl_vimvcxt);
     1408    }
    13801409#if defined (READLINE_CALLBACKS)
    13811410  else if (RL_ISSTATE (RL_STATE_CALLBACK))
    13821411    {
  • lib/sh/eaccess.c

    diff -Naur bash-4.2.orig/lib/sh/eaccess.c bash-4.2/lib/sh/eaccess.c
    old new  
    8282     const char *path;
    8383     struct stat *finfo;
    8484{
     85  static char *pbuf = 0;
     86
    8587  if (*path == '\0')
    8688    {
    8789      errno = ENOENT;
     
    106108     trailing slash.  Make sure /dev/fd/xx really uses DEV_FD_PREFIX/xx.
    107109     On most systems, with the notable exception of linux, this is
    108110     effectively a no-op. */
    109       char pbuf[32];
     111      pbuf = xrealloc (pbuf, sizeof (DEV_FD_PREFIX) + strlen (path + 8));
    110112      strcpy (pbuf, DEV_FD_PREFIX);
    111113      strcat (pbuf, path + 8);
    112114      return (stat (pbuf, finfo));
  • lib/sh/zread.c

    diff -Naur bash-4.2.orig/lib/sh/zread.c bash-4.2/lib/sh/zread.c
    old new  
    160160zsyncfd (fd)
    161161     int fd;
    162162{
    163   off_t off;
    164   int r;
     163  off_t off, r;
    165164
    166165  off = lused - lind;
    167166  r = 0;
    168167  if (off > 0)
    169168    r = lseek (fd, -off, SEEK_CUR);
    170169
    171   if (r >= 0)
     170  if (r != -1)
    172171    lused = lind = 0;
    173172}
  • parse.y

    diff -Naur bash-4.2.orig/parse.y bash-4.2/parse.y
    old new  
    24992499         We do this only if it is time to do so. Notice that only here
    25002500         is the mail alarm reset; nothing takes place in check_mail ()
    25012501         except the checking of mail.  Please don't change this. */
    2502       if (prompt_is_ps1 && time_to_check_mail ())
     2502      if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ())
    25032503        {
    25042504          check_mail ();
    25052505          reset_mail_timer ();
     
    38423842     int flags;
    38433843{
    38443844  sh_parser_state_t ps;
     3845  sh_input_line_state_t ls;
    38453846  int orig_ind, nc, sflags;
    38463847  char *ret, *s, *ep, *ostring;
    38473848
     
    38493850  orig_ind = *indp;
    38503851  ostring = string;
    38513852
     3853/*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/
    38523854  sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE;
    38533855  if (flags & SX_NOLONGJMP)
    38543856    sflags |= SEVAL_NOLONGJMP;
    38553857  save_parser_state (&ps);
     3858  save_input_line_state (&ls);
    38563859
    38573860  /*(*/
    38583861  parser_state |= PST_CMDSUBST|PST_EOFTOKEN;    /* allow instant ')' */ /*(*/
     
    38613864
    38623865  restore_parser_state (&ps);
    38633866  reset_parser ();
     3867  /* reset_parser clears shell_input_line and associated variables */
     3868  restore_input_line_state (&ls);
    38643869  if (interactive)
    38653870    token_to_read = 0;
    38663871
     
    48954900      return (current_command_line_count == 2 ? "\n" : "");
    48964901    }
    48974902
     4903  if (parser_state & PST_COMPASSIGN)
     4904    return (" ");
     4905
    48984906  /* First, handle some special cases. */
    48994907  /*(*/
    49004908  /* If we just read `()', assume it's a function definition, and don't
     
    51355143            case 'A':
    51365144              /* Make the current time/date into a string. */
    51375145              (void) time (&the_time);
     5146#if defined (HAVE_TZSET)
     5147              sv_tz ("TZ");             /* XXX -- just make sure */
     5148#endif
    51385149              tm = localtime (&the_time);
    51395150
    51405151              if (c == 'd')
     
    59055916  ps->expand_aliases = expand_aliases;
    59065917  ps->echo_input_at_read = echo_input_at_read;
    59075918
     5919  ps->token = token;
     5920  ps->token_buffer_size = token_buffer_size;
     5921  /* Force reallocation on next call to read_token_word */
     5922  token = 0;
     5923  token_buffer_size = 0;
     5924
    59085925  return (ps);
    59095926}
    59105927
     
    59465963
    59475964  expand_aliases = ps->expand_aliases;
    59485965  echo_input_at_read = ps->echo_input_at_read;
     5966
     5967  FREE (token);
     5968  token = ps->token;
     5969  token_buffer_size = ps->token_buffer_size;
     5970}
     5971
     5972sh_input_line_state_t *
     5973save_input_line_state (ls)
     5974     sh_input_line_state_t *ls;
     5975{
     5976  if (ls == 0)
     5977    ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t));
     5978  if (ls == 0)
     5979    return ((sh_input_line_state_t *)NULL);
     5980
     5981  ls->input_line = shell_input_line;
     5982  ls->input_line_size = shell_input_line_size;
     5983  ls->input_line_len = shell_input_line_len;
     5984  ls->input_line_index = shell_input_line_index;
     5985
     5986  /* force reallocation */
     5987  shell_input_line = 0;
     5988  shell_input_line_size = shell_input_line_len = shell_input_line_index = 0;
     5989}
     5990
     5991void
     5992restore_input_line_state (ls)
     5993     sh_input_line_state_t *ls;
     5994{
     5995  FREE (shell_input_line);
     5996  shell_input_line = ls->input_line;
     5997  shell_input_line_size = ls->input_line_size;
     5998  shell_input_line_len = ls->input_line_len;
     5999  shell_input_line_index = ls->input_line_index;
     6000
     6001  set_line_mbstate ();
    59496002}
    59506003
    59516004/************************************************
  • patchlevel.h

    diff -Naur bash-4.2.orig/patchlevel.h bash-4.2/patchlevel.h
    old new  
    2525   regexp `^#define[    ]*PATCHLEVEL', since that's what support/mkversion.sh
    2626   looks for to find the patch level (for the sccs version string). */
    2727
    28 #define PATCHLEVEL 0
     28#define PATCHLEVEL 37
    2929
    3030#endif /* _PATCHLEVEL_H_ */
  • pathexp.c

    diff -Naur bash-4.2.orig/pathexp.c bash-4.2/pathexp.c
    old new  
    196196        {
    197197          if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
    198198            continue;
    199           if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
     199          if (pathname[i+1] != CTLESC && (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
    200200            continue;
    201201          temp[j++] = '\\';
    202202          i++;
  • print_cmd.c

    diff -Naur bash-4.2.orig/print_cmd.c bash-4.2/print_cmd.c
    old new  
    315315          cprintf ("( ");
    316316          skip_this_indent++;
    317317          make_command_string_internal (command->value.Subshell->command);
     318          PRINT_DEFERRED_HEREDOCS ("");
    318319          cprintf (" )");
    319320          break;
    320321
     
    592593  newline ("do\n");
    593594  indentation += indentation_amount;
    594595  make_command_string_internal (arith_for_command->action);
     596  PRINT_DEFERRED_HEREDOCS ("");
    595597  semicolon ();
    596598  indentation -= indentation_amount;
    597599  newline ("done");
     
    653655    }
    654656
    655657  make_command_string_internal (group_command->command);
     658  PRINT_DEFERRED_HEREDOCS ("");
    656659
    657660  if (inside_function_def)
    658661    {
  • shell.h

    diff -Naur bash-4.2.orig/shell.h bash-4.2/shell.h
    old new  
    136136  int parser_state;
    137137  int *token_state;
    138138
     139  char *token;
     140  int token_buffer_size;
     141
    139142  /* input line state -- line number saved elsewhere */
    140143  int input_line_terminator;
    141144  int eof_encountered;
     
    166169 
    167170} sh_parser_state_t;
    168171
     172typedef struct _sh_input_line_state_t {
     173  char *input_line;
     174  int input_line_index;
     175  int input_line_size;
     176  int input_line_len;
     177} sh_input_line_state_t;
     178
    169179/* Let's try declaring these here. */
    170180extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *));
    171181extern void restore_parser_state __P((sh_parser_state_t *));
     182
     183extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *));
     184extern void restore_input_line_state __P((sh_input_line_state_t *));
  • bash-4.2

    diff -Naur bash-4.2.orig/sig.c bash-4.2/sig.c
    old new  
    4646
    4747#if defined (READLINE)
    4848#  include "bashline.h"
     49#  include <readline/readline.h>
    4950#endif
    5051
    5152#if defined (HISTORY)
     
    6263#if defined (HISTORY)
    6364extern int history_lines_this_session;
    6465#endif
     66extern int no_line_editing;
    6567
    6668extern void initialize_siglist ();
    6769
     
    505507    {
    506508#if defined (HISTORY)
    507509      /* XXX - will inhibit history file being written */
    508       history_lines_this_session = 0;
     510#  if defined (READLINE)
     511      if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
     512#  endif
     513        history_lines_this_session = 0;
    509514#endif
    510515      terminate_immediately = 0;
    511516      termsig_handler (sig);
  • subst.c

    diff -Naur bash-4.2.orig/subst.c bash-4.2/subst.c
    old new  
    366366      f &= ~W_ASSNBLTIN;
    367367      fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
    368368    }
     369  if (f & W_ASSNGLOBAL)
     370    {
     371      f &= ~W_ASSNGLOBAL;
     372      fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
     373    }
    369374  if (f & W_COMPASSIGN)
    370375    {
    371376      f &= ~W_COMPASSIGN;
     
    13791384  slen = strlen (string + *sindex) + *sindex;
    13801385
    13811386  /* The handling of dolbrace_state needs to agree with the code in parse.y:
    1382      parse_matched_pair() */
    1383   dolbrace_state = 0;
    1384   if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
    1385     dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
     1387     parse_matched_pair().  The different initial value is to handle the
     1388     case where this function is called to parse the word in
     1389     ${param op word} (SX_WORD). */
     1390  dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
     1391  if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
     1392    dolbrace_state = DOLBRACE_QUOTE;
    13861393
    13871394  i = *sindex;
    13881395  while (c = string[i])
     
    28012808    }
    28022809  else if (assign_list)
    28032810    {
    2804       if (word->flags & W_ASSIGNARG)
     2811      if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
    28052812        aflags |= ASS_MKLOCAL;
    28062813      if (word->flags & W_ASSIGNASSOC)
    28072814        aflags |= ASS_MKASSOC;
     
    33713378  if (string == 0 || *string == '\0')
    33723379    return (WORD_LIST *)NULL;
    33733380
    3374   td.flags = 0;
     3381  td.flags = W_NOSPLIT2;                /* no splitting, remove "" and '' */
    33753382  td.word = string;
    33763383  tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
    33773384  return (tresult);
     
    37043711            break;
    37053712        }
    37063713      else if (string[i] == CTLNUL)
    3707         i++;
     3714        {
     3715          i++;
     3716          continue;
     3717        }
    37083718
    37093719      prev_i = i;
    37103720      ADVANCE_CHAR (string, slen, i);
     
    41564166  simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
    41574167#if defined (EXTENDED_GLOB)
    41584168  if (extended_glob)
    4159     simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
     4169    simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
    41604170#endif
    41614171
    41624172  /* If the pattern doesn't match anywhere in the string, go ahead and
     
    46074617  if (ifs_firstc == 0)
    46084618#endif
    46094619    word->flags |= W_NOSPLIT;
     4620  word->flags |= W_NOSPLIT2;
    46104621  result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
    46114622  expand_no_split_dollar_star = 0;
    46124623
     
    57985809         is the only expansion that creates more than one word. */
    57995810      if (qdollaratp && ((hasdol && quoted) || l->next))
    58005811        *qdollaratp = 1;
     5812      /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is
     5813         a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the
     5814         flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the
     5815         expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
     5816         (which is more paranoia than anything else), we need to return the
     5817         quoted null string and set the flags to indicate it. */
     5818      if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL(temp) && QUOTED_NULL(l->word->word) && (l->word->flags & W_HASQUOTEDNULL))
     5819        {
     5820          w->flags |= W_HASQUOTEDNULL;
     5821        }
    58015822      dispose_words (l);
    58025823    }
    58035824  else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && hasdol)
     
    71767197    {
    71777198      /* Extract the contents of the ${ ... } expansion
    71787199         according to the Posix.2 rules. */
    7179       value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
     7200      value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
    71807201      if (string[sindex] == RBRACE)
    71817202        sindex++;
    71827203      else
     
    72687289    default:
    72697290    case '\0':
    72707291    bad_substitution:
     7292      last_command_exit_value = EXECUTION_FAILURE;
    72717293      report_error (_("%s: bad substitution"), string ? string : "??");
    72727294      FREE (value);
    72737295      FREE (temp);
     
    79007922
    79017923  /* State flags */
    79027924  int had_quoted_null;
    7903   int has_dollar_at;
     7925  int has_dollar_at, temp_has_dollar_at;
    79047926  int tflag;
    79057927  int pflags;                   /* flags passed to param_expand */
    79067928
     
    81058127          if (expanded_something)
    81068128            *expanded_something = 1;
    81078129
    8108           has_dollar_at = 0;
     8130          temp_has_dollar_at = 0;
    81098131          pflags = (word->flags & W_NOCOMSUB) ? PF_NOCOMSUB : 0;
    81108132          if (word->flags & W_NOSPLIT2)
    81118133            pflags |= PF_NOSPLIT2;
    81128134          tword = param_expand (string, &sindex, quoted, expanded_something,
    8113                                &has_dollar_at, &quoted_dollar_at,
     8135                               &temp_has_dollar_at, &quoted_dollar_at,
    81148136                               &had_quoted_null, pflags);
     8137          has_dollar_at += temp_has_dollar_at;
    81158138
    81168139          if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal)
    81178140            {
     
    81298152          temp = tword->word;
    81308153          dispose_word_desc (tword);
    81318154
     8155          /* Kill quoted nulls; we will add them back at the end of
     8156             expand_word_internal if nothing else in the string */
     8157          if (had_quoted_null && temp && QUOTED_NULL (temp))
     8158            {
     8159              FREE (temp);
     8160              temp = (char *)NULL;
     8161            }
     8162
    81328163          goto add_string;
    81338164          break;
    81348165
     
    82448275
    82458276              temp = (char *)NULL;
    82468277
    8247               has_dollar_at = 0;
     8278              temp_has_dollar_at = 0;   /* XXX */
    82488279              /* Need to get W_HASQUOTEDNULL flag through this function. */
    8249               list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &has_dollar_at, (int *)NULL);
     8280              list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &temp_has_dollar_at, (int *)NULL);
     8281              has_dollar_at += temp_has_dollar_at;
    82508282
    82518283              if (list == &expand_word_error || list == &expand_word_fatal)
    82528284                {
     
    85338565        tword->flags |= W_NOEXPAND;     /* XXX */
    85348566      if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
    85358567        tword->flags |= W_QUOTED;
    8536       if (had_quoted_null)
     8568      if (had_quoted_null && QUOTED_NULL (istring))
    85378569        tword->flags |= W_HASQUOTEDNULL;
    85388570      list = make_word_list (tword, (WORD_LIST *)NULL);
    85398571    }
     
    85648596            tword->flags |= W_NOGLOB;
    85658597          if (word->flags & W_NOEXPAND)
    85668598            tword->flags |= W_NOEXPAND;
    8567           if (had_quoted_null)
     8599          if (had_quoted_null && QUOTED_NULL (istring))
    85688600            tword->flags |= W_HASQUOTEDNULL;    /* XXX */
    85698601          list = make_word_list (tword, (WORD_LIST *)NULL);
    85708602        }
  • subst.h

    diff -Naur bash-4.2.orig/subst.h bash-4.2/subst.h
    old new  
    5656#define SX_NOLONGJMP    0x0040  /* don't longjmp on fatal error */
    5757#define SX_ARITHSUB     0x0080  /* extracting $(( ... )) (currently unused) */
    5858#define SX_POSIXEXP     0x0100  /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
     59#define SX_WORD         0x0200  /* extracting word in ${param op word} */
    5960
    6061/* Remove backslashes which are quoting backquotes from STRING.  Modifies
    6162   STRING, and returns a pointer to it. */
  • support/shobj-conf

    diff -Naur bash-4.2.orig/support/shobj-conf bash-4.2/support/shobj-conf
    old new  
    157157        ;;
    158158
    159159# Darwin/MacOS X
    160 darwin[89]*|darwin10*)
     160darwin[89]*|darwin1[012]*)
    161161        SHOBJ_STATUS=supported
    162162        SHLIB_STATUS=supported
    163163       
     
    186186        SHLIB_LIBSUFF='dylib'
    187187
    188188        case "${host_os}" in
    189         darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
     189        darwin[789]*|darwin1[012]*)     SHOBJ_LDFLAGS=''
    190190                        SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
    191191                        ;;
    192192        *)              SHOBJ_LDFLAGS='-dynamic'
  • tests/shopt.right

    diff -Naur bash-4.2.orig/tests/shopt.right bash-4.2/tests/shopt.right
    old new  
    1212shopt -u compat32
    1313shopt -u compat40
    1414shopt -u compat41
     15shopt -u direxpand
    1516shopt -u dirspell
    1617shopt -u dotglob
    1718shopt -u execfail
     
    6869shopt -u compat32
    6970shopt -u compat40
    7071shopt -u compat41
     72shopt -u direxpand
    7173shopt -u dirspell
    7274shopt -u dotglob
    7375shopt -u execfail
     
    101103compat32        off
    102104compat40        off
    103105compat41        off
     106direxpand       off
    104107dirspell        off
    105108dotglob         off
    106109execfail        off
  • variables.c

    diff -Naur bash-4.2.orig/variables.c bash-4.2/variables.c
    old new  
    36533653  return n;
    36543654}
    36553655
     3656int
     3657chkexport (name)
     3658     char *name;
     3659{
     3660  SHELL_VAR *v;
     3661
     3662  v = find_variable (name);
     3663  if (v && exported_p (v))
     3664    {
     3665      array_needs_making = 1;
     3666      maybe_make_export_env ();
     3667      return 1;
     3668    }
     3669  return 0;
     3670}
     3671
    36563672void
    36573673maybe_make_export_env ()
    36583674{
     
    42144230  { "TEXTDOMAIN", sv_locale },
    42154231  { "TEXTDOMAINDIR", sv_locale },
    42164232
    4217 #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
     4233#if defined (HAVE_TZSET)
    42184234  { "TZ", sv_tz },
    42194235#endif
    42204236
     
    45584574}
    45594575#endif /* HISTORY */
    45604576
    4561 #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
     4577#if defined (HAVE_TZSET)
    45624578void
    45634579sv_tz (name)
    45644580     char *name;
    45654581{
    4566   tzset ();
     4582  if (chkexport (name))
     4583    tzset ();
    45674584}
    45684585#endif
    45694586
  • variables.h

    diff -Naur bash-4.2.orig/variables.h bash-4.2/variables.h
    old new  
    313313
    314314extern void sort_variables __P((SHELL_VAR **));
    315315
     316extern int chkexport __P((char *));
    316317extern void maybe_make_export_env __P((void));
    317318extern void update_export_env_inplace __P((char *, int, char *));
    318319extern void put_command_name_into_env __P((char *));
Note: See TracBrowser for help on using the repository browser.