source: patches/bash-3.2-branch_update-1.patch@ 60ec2de

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 60ec2de was d849dd4, checked in by Jim Gifford <clfs@…>, 16 years ago

Changed Patches to Bash

  • Property mode set to 100644
File size: 74.5 KB
  • array.c

    Submitted By: Jim Gifford (jim at cross-lfs dot org)
    Date: 01-08-2009
    Initial Package Version: 3.2
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 3.2-048
    
    diff -Naur bash-3.2.orig/array.c bash-3.2/array.c
    old new  
    120120        return(a1);
    121121}
    122122
    123 #ifdef INCLUDE_UNUSED
    124123/*
    125124 * Make and return a new array composed of the elements in array A from
    126125 * S to E, inclusive.
     
    141140        for (p = s, i = 0; p != e; p = element_forw(p), i++) {
    142141                n = array_create_element (element_index(p), element_value(p));
    143142                ADD_BEFORE(a->head, n);
    144                 mi = element_index(ae);
     143                mi = element_index(n);
    145144        }
    146145        a->num_elements = i;
    147146        a->max_index = mi;
    148147        return a;
    149148}
    150 #endif
    151149
    152150/*
    153151 * Walk the array, calling FUNC once for each element, with the array
     
    300298        return array;
    301299}
    302300
     301ARRAY   *
     302array_quote_escapes(array)
     303ARRAY   *array;
     304{
     305        ARRAY_ELEMENT   *a;
     306        char    *t;
     307
     308        if (array == 0 || array_head(array) == 0 || array_empty(array))
     309                return (ARRAY *)NULL;
     310        for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
     311                t = quote_escapes (a->value);
     312                FREE(a->value);
     313                a->value = t;
     314        }
     315        return array;
     316}
     317
    303318/*
    304319 * Return a string whose elements are the members of array A beginning at
    305320 * index START and spanning NELEM members.  Null elements are counted.
     
    311326arrayind_t      start, nelem;
    312327int     starsub, quoted;
    313328{
     329        ARRAY           *a2;
    314330        ARRAY_ELEMENT   *h, *p;
    315331        arrayind_t      i;
    316         char            *ifs, sep[2];
     332        char            *ifs, sep[2], *t;
    317333
    318334        p = a ? array_head (a) : 0;
    319335        if (p == 0 || array_empty (a) || start > array_max_index(a))
     
    336352        for (i = 0, h = p; p != a->head && i < nelem; i++, p = element_forw(p))
    337353                ;
    338354
     355        a2 = array_slice(a, h, p);
     356
     357        if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
     358                array_quote(a2);
     359        else
     360                array_quote_escapes(a2);
     361
    339362        if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) {
    340363                ifs = getifs();
    341364                sep[0] = ifs ? *ifs : '\0';
     
    343366                sep[0] = ' ';
    344367        sep[1] = '\0';
    345368
    346         return (array_to_string_internal (h, p, sep, quoted));
     369        t = array_to_string (a2, sep, 0);
     370        array_dispose(a2);
     371
     372        return t;
    347373}
    348374
    349375char *
     
    367393        }
    368394
    369395        if (mflags & MATCH_QUOTED)
    370                 array_quote (a2);
     396                array_quote(a2);
     397        else
     398                array_quote_escapes(a2);
    371399        if (mflags & MATCH_STARSUB) {
    372400                ifs = getifs();
    373401                sifs[0] = ifs ? *ifs : '\0';
     
    655683                is = inttostr (element_index(ae), indstr, sizeof(indstr));
    656684                valstr = element_value (ae) ? sh_double_quote (element_value(ae))
    657685                                            : (char *)NULL;
    658                 elen = STRLEN (indstr) + 8 + STRLEN (valstr);
     686                elen = STRLEN (is) + 8 + STRLEN (valstr);
    659687                RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize);
    660688
    661689                result[rlen++] = '[';
  • array.h

    diff -Naur bash-3.2.orig/array.h bash-3.2/array.h
    old new  
    5555extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *));
    5656extern int      array_shift_element __P((ARRAY *, char *));
    5757extern ARRAY    *array_quote __P((ARRAY *));
     58extern ARRAY    *array_quote_escapes __P((ARRAY *));
    5859
    5960extern char     *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int));
    6061extern char     *array_patsub __P((ARRAY *, char *, char *, int));
  • arrayfunc.c

    diff -Naur bash-3.2.orig/arrayfunc.c bash-3.2/arrayfunc.c
    old new  
    618618  if (expok == 0)
    619619    {
    620620      last_command_exit_value = EXECUTION_FAILURE;
     621
     622      top_level_cleanup ();     
    621623      jump_to_top_level (DISCARD);
    622624    }
    623625  return val;
     
    720722  if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']')
    721723    {
    722724      if (rtype)
    723         *rtype = 1;
     725        *rtype = (t[0] == '*') ? 1 : 2;
    724726      if (allow_all == 0)
    725727        {
    726728          err_badarraysub (s);
  • bashhist.c

    diff -Naur bash-3.2.orig/bashhist.c bash-3.2/bashhist.c
    old new  
    8080   list.  This is different than the user-controlled behaviour; this
    8181   becomes zero when we read lines from a file, for example. */
    8282int remember_on_history = 1;
     83int enable_history_list = 1;    /* value for `set -o history' */
    8384
    8485/* The number of lines that Bash has added to this history session.  The
    8586   difference between the number of the top element in the history list
     
    234235  history_expansion = interact != 0;
    235236  history_expansion_inhibited = 1;
    236237#endif
    237   remember_on_history = interact != 0;
     238  remember_on_history = enable_history_list = interact != 0;
    238239  history_inhibit_expansion_function = bash_history_inhibit_expansion;
    239240}
    240241
  • bashhist.h

    diff -Naur bash-3.2.orig/bashhist.h bash-3.2/bashhist.h
    old new  
    3131#define HC_IGNBOTH      (HC_IGNSPACE|HC_IGNDUPS)
    3232
    3333extern int remember_on_history;
     34extern int enable_history_list;         /* value for `set -o history' */
     35extern int literal_history;             /* controlled by `shopt lithist' */
     36extern int force_append_history;
    3437extern int history_lines_this_session;
    3538extern int history_lines_in_file;
    3639extern int history_expansion;
  • bashline.c

    diff -Naur bash-3.2.orig/bashline.c bash-3.2/bashline.c
    old new  
    23572357  if (should_expand_dirname) 
    23582358    {
    23592359      new_dirname = savestring (local_dirname);
    2360       wl = expand_prompt_string (new_dirname, 0);       /* does the right thing */
     2360      wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB);   /* does the right thing */
    23612361      if (wl)
    23622362        {
    23632363          *dirname = string_list (wl);
  • builtins/common.c

    diff -Naur bash-3.2.orig/builtins/common.c bash-3.2/builtins/common.c
    old new  
    1 /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
     1/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
    22
    33   This file is part of GNU Bash, the Bourne Again SHell.
    44
     
    131131  if (list)
    132132    {
    133133      builtin_error (_("too many arguments"));
     134      top_level_cleanup ();
    134135      jump_to_top_level (DISCARD);
    135136    }
    136137}
     
    395396          if (fatal)
    396397            throw_to_top_level ();
    397398          else
    398             jump_to_top_level (DISCARD);
     399            {
     400              top_level_cleanup ();
     401              jump_to_top_level (DISCARD);
     402            }
    399403        }
    400404      no_args (list->next);
    401405    }
     
    475479
    476480  if (the_current_working_directory == 0)
    477481    {
     482#if defined (GETCWD_BROKEN)
     483      the_current_working_directory = getcwd (0, PATH_MAX);
     484#else
    478485      the_current_working_directory = getcwd (0, 0);
     486#endif
    479487      if (the_current_working_directory == 0)
    480488        {
    481489          fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
  • builtins/evalstring.c

    diff -Naur bash-3.2.orig/builtins/evalstring.c bash-3.2/builtins/evalstring.c
    old new  
    6767
    6868static int cat_file __P((REDIRECT *));
    6969
     70#if defined (HISTORY)
     71static void
     72set_history_remembering ()
     73{
     74  remember_on_history = enable_history_list;
     75}
     76#endif
     77
    7078/* How to force parse_and_execute () to clean up after itself. */
    7179void
    7280parse_and_execute_cleanup ()
     
    115123  lreset = flags & SEVAL_RESETLINE;
    116124
    117125#if defined (HISTORY)
    118   unwind_protect_int (remember_on_history);     /* can be used in scripts */
     126  if (parse_and_execute_level == 0)
     127    add_unwind_protect (set_history_remembering, (char *)NULL);
     128  else
     129    unwind_protect_int (remember_on_history);   /* can be used in scripts */
    119130#  if defined (BANG_HISTORY)
    120131  if (interactive_shell)
    121132    {
     
    237248               *   parse_and_execute has not been called recursively AND
    238249               *   we're not running a trap AND
    239250               *   we have parsed the full command (string == '\0') AND
     251               *   we're not going to run the exit trap AND
    240252               *   we have a simple command without redirections AND
    241253               *   the command is not being timed AND
    242254               *   the command's return status is not being inverted
     
    247259                  running_trap == 0 &&
    248260                  *bash_input.location.string == '\0' &&
    249261                  command->type == cm_simple &&
    250                   !command->redirects && !command->value.Simple->redirects &&
     262                  signal_is_trapped (EXIT_TRAP) == 0 &&
     263                  command->redirects == 0 && command->value.Simple->redirects == 0 &&
    251264                  ((command->flags & CMD_TIME_PIPELINE) == 0) &&
    252265                  ((command->flags & CMD_INVERT_RETURN) == 0))
    253266                {
  • builtins/printf.def

    diff -Naur bash-3.2.orig/builtins/printf.def bash-3.2/builtins/printf.def
    old new  
    11This file is printf.def, from which is created printf.c.
    22It implements the builtin "printf" in Bash.
    33
    4 Copyright (C) 1997-2005 Free Software Foundation, Inc.
     4Copyright (C) 1997-2007 Free Software Foundation, Inc.
    55
    66This file is part of GNU Bash, the Bourne Again SHell.
    77
     
    4949#  define INT_MIN               (-2147483647-1)
    5050#endif
    5151
     52#if defined (PREFER_STDARG)
     53#  include <stdarg.h>
     54#else
     55#  include <varargs.h>
     56#endif
     57
    5258#include <stdio.h>
    5359#include <chartypes.h>
    5460
     
    6470#include "bashgetopt.h"
    6571#include "common.h"
    6672
     73#if defined (PRI_MACROS_BROKEN)
     74#  undef PRIdMAX
     75#endif
     76
    6777#if !defined (PRIdMAX)
    6878#  if HAVE_LONG_LONG
    6979#    define PRIdMAX     "lld"
     
    151161#define SKIP1 "#'-+ 0"
    152162#define LENMODS "hjlLtz"
    153163
     164#ifndef HAVE_ASPRINTF
     165extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
     166#endif
     167
    154168static void printf_erange __P((char *));
    155169static int printstr __P((char *, char *, int, int, int));
    156170static int tescape __P((char *, char *, int *));
  • builtins/read.def

    diff -Naur bash-3.2.orig/builtins/read.def bash-3.2/builtins/read.def
    old new  
    127127     WORD_LIST *list;
    128128{
    129129  register char *varname;
    130   int size, i, nr, pass_next, saw_escape, eof, opt, retval, code;
    131   int input_is_tty, input_is_pipe, unbuffered_read;
     130  int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
     131  int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
    132132  int raw, edit, nchars, silent, have_timeout, fd;
    133133  unsigned int tmout;
    134134  intmax_t intval;
    135135  char c;
    136136  char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
    137   char *e, *t, *t1;
     137  char *e, *t, *t1, *ps2, *tofree;
    138138  struct stat tsb;
    139139  SHELL_VAR *var;
    140140#if defined (ARRAY_VARS)
     
    148148  USE_VAR(size);
    149149  USE_VAR(i);
    150150  USE_VAR(pass_next);
     151  USE_VAR(print_ps2);
    151152  USE_VAR(saw_escape);
    152153  USE_VAR(input_is_pipe);
    153154/*  USE_VAR(raw); */
     
    163164  USE_VAR(rlind);
    164165#endif
    165166  USE_VAR(list);
     167  USE_VAR(ps2);
    166168
    167169  i = 0;                /* Index into the string that we are reading. */
    168170  raw = edit = 0;       /* Not reading raw input by default. */
     
    386388  setmode (0, O_TEXT);
    387389#endif
    388390
    389   for (eof = retval = 0;;)
     391  ps2 = 0;
     392  for (print_ps2 = eof = retval = 0;;)
    390393    {
    391394#if defined (READLINE)
    392395      if (edit)
     
    412415        {
    413416#endif
    414417
     418      if (print_ps2)
     419        {
     420          if (ps2 == 0)
     421            ps2 = get_string_value ("PS2");
     422          fprintf (stderr, "%s", ps2 ? ps2 : "");
     423          fflush (stderr);
     424          print_ps2 = 0;
     425        }
     426
    415427      if (unbuffered_read)
    416428        retval = zread (fd, &c, 1);
    417429      else
     
    440452        {
    441453          pass_next = 0;
    442454          if (c == '\n')
    443             i--;                /* back up over the CTLESC */
     455            {
     456              i--;              /* back up over the CTLESC */
     457              if (interactive && input_is_tty && raw == 0)
     458                print_ps2 = 1;
     459            }
    444460          else
    445461            goto add_char;
    446462          continue;
     
    658674#else
    659675  /* Check whether or not the number of fields is exactly the same as the
    660676     number of variables. */
     677  tofree = NULL;
    661678  if (*input_string)
    662679    {
    663680      t1 = input_string;
    664681      t = get_word_from_string (&input_string, ifs_chars, &e);
    665682      if (*input_string == 0)
    666         input_string = t;
     683        tofree = input_string = t;
    667684      else
    668685        input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape);
    669686    }
     
    678695  else
    679696    var = bind_read_variable (list->word->word, input_string);
    680697  stupidly_hack_special_variables (list->word->word);
     698  FREE (tofree);
     699
    681700  if (var)
    682701    VUNSETATTR (var, att_invisible);
    683702  xfree (orig_input_string);
  • builtins/set.def

    diff -Naur bash-3.2.orig/builtins/set.def bash-3.2/builtins/set.def
    old new  
    189189  { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL  },
    190190#endif /* BANG_HISTORY */
    191191#if defined (HISTORY)
    192   { "history",   '\0', &remember_on_history, bash_set_history, (setopt_get_func_t *)NULL },
     192  { "history",   '\0', &enable_history_list, bash_set_history, (setopt_get_func_t *)NULL },
    193193#endif
    194194  { "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL },
    195195  { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL },
     
    381381{
    382382  if (on_or_off == FLAG_ON)
    383383    {
     384      enable_history_list = 1;
    384385      bash_history_enable ();
    385386      if (history_lines_this_session == 0)
    386387        load_history ();
    387388    }
    388389  else
    389     bash_history_disable ();
    390   return (1 - remember_on_history);
     390    {
     391      enable_history_list = 0;
     392      bash_history_disable ();
     393    }
     394  return (1 - enable_history_list);
    391395}
    392396#endif
    393397
     
    565569reset_shell_options ()
    566570{
    567571#if defined (HISTORY)
    568   remember_on_history = 1;
     572  remember_on_history = enable_history_list = 1;
    569573#endif
    570574  ignoreeof = 0;
    571575}
  • builtins/shopt.def

    diff -Naur bash-3.2.orig/builtins/shopt.def bash-3.2/builtins/shopt.def
    old new  
    101101
    102102static int set_shellopts_after_change __P((int));
    103103
     104static int set_compatibility_level __P((int));
     105
    104106#if defined (RESTRICTED_SHELL)
    105107static int set_restricted_shell __P((int));
    106108#endif
    107109
    108110static int shopt_login_shell;
     111static int shopt_compat31;
    109112
    110113typedef int shopt_set_func_t __P((int));
    111114
     
    121124#if defined (HISTORY)
    122125  { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
    123126#endif
     127  { "compat31", &shopt_compat31, set_compatibility_level },
    124128  { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
    125129  { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
    126130  { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
     
    459463  return (0);
    460464}
    461465
     466static int
     467set_compatibility_level (mode)
     468     int mode;
     469{
     470  /* Need to change logic here as we add more compatibility levels */
     471  if (shopt_compat31)
     472    shell_compatibility_level = 31;
     473  else
     474    shell_compatibility_level = 32;
     475  return 0;
     476}
     477
    462478#if defined (RESTRICTED_SHELL)
    463479/* Don't allow the value of restricted_shell to be modified. */
    464480
  • config-bot.h

    diff -Naur bash-3.2.orig/config-bot.h bash-3.2/config-bot.h
    old new  
    11/* config-bot.h */
    22/* modify settings or make new ones based on what autoconf tells us. */
    33
    4 /* Copyright (C) 1989-2002 Free Software Foundation, Inc.
     4/* Copyright (C) 1989-2007 Free Software Foundation, Inc.
    55
    66   This file is part of GNU Bash, the Bourne Again SHell.
    77
     
    7070#  define TERMIOS_MISSING
    7171#endif
    7272
    73 /* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
    74    the replacement in getcwd.c will be built. */
    75 #if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
     73/* If we have a getcwd(3), but one that does not dynamically allocate memory,
     74   #undef HAVE_GETCWD so the replacement in getcwd.c will be built.  We do
     75   not do this on Solaris, because their implementation of loopback mounts
     76   breaks the traditional file system assumptions that getcwd uses. */
     77#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN) && !defined (SOLARIS)
    7678#  undef HAVE_GETCWD
    7779#endif
    7880
  • config.h.in

    diff -Naur bash-3.2.orig/config.h.in bash-3.2/config.h.in
    old new  
    11/* config.h -- Configuration file for bash. */
    22
    3 /* Copyright (C) 1987-2006 Free Software Foundation, Inc.
     3/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
    44
    55   This file is part of GNU Bash, the Bourne Again SHell.
    66
     
    413413
    414414#undef HAVE_DECL_STRTOLD
    415415
     416#undef PRI_MACROS_BROKEN
     417
    416418#undef STRTOLD_BROKEN
    417419
    418420/* Define if WCONTINUED is defined in system headers, but rejected by waitpid */
     
    10061008/* Define if you have the `dcgettext' function. */
    10071009#undef HAVE_DCGETTEXT
    10081010
     1011/* Define if you have the `localeconv' function. */
     1012#undef HAVE_LOCALECONV
     1013
    10091014/* Define if your system has a working `malloc' function. */
    10101015/* #undef HAVE_MALLOC */
    10111016
  • configure

    diff -Naur bash-3.2.orig/configure bash-3.2/configure
    old new  
    48714871                # static version specified as -llibname to override the
    48724872                # dynamic version
    48734873                case "${host_os}" in
    4874                 darwin8*)       READLINE_LIB='${READLINE_LIBRARY}' ;;
     4874                darwin[89]*)    READLINE_LIB='${READLINE_LIBRARY}' ;;
    48754875                *)              READLINE_LIB=-lreadline ;;
    48764876                esac
    48774877        fi
     
    2731627316sco3.2v4*)      LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
    2731727317sco3.2*)        LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
    2731827318sunos4*)        LOCAL_CFLAGS=-DSunOS4 ;;
    27319 solaris2.5*)    LOCAL_CFLAGS=-DSunOS5 ;;
     27319solaris2.5*)    LOCAL_CFLAGS="-DSunOS5 -DSOLARIS" ;;
     27320solaris2*)      LOCAL_CFLAGS=-DSOLARIS ;;
    2732027321lynxos*)        LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
    2732127322linux*)         LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
    2732227323                case "`uname -r`" in
  • configure.in

    diff -Naur bash-3.2.orig/configure.in bash-3.2/configure.in
    old new  
    55dnl
    66dnl Process this file with autoconf to produce a configure script.
    77
    8 # Copyright (C) 1987-2006 Free Software Foundation, Inc.
     8# Copyright (C) 1987-2007 Free Software Foundation, Inc.
    99
    1010# This program is free software; you can redistribute it and/or modify
    1111# it under the terms of the GNU General Public License as published by
     
    518518                # static version specified as -llibname to override the
    519519                # dynamic version
    520520                case "${host_os}" in
    521                 darwin8*)       READLINE_LIB='${READLINE_LIBRARY}' ;;
     521                darwin[[89]]*)  READLINE_LIB='${READLINE_LIBRARY}' ;;
    522522                *)              READLINE_LIB=-lreadline ;;
    523523                esac
    524524        fi
     
    991991sco3.2v4*)      LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DPATH_MAX=1024" ;;
    992992sco3.2*)        LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
    993993sunos4*)        LOCAL_CFLAGS=-DSunOS4 ;;
    994 solaris2.5*)    LOCAL_CFLAGS=-DSunOS5 ;;
     994solaris2.5*)    LOCAL_CFLAGS="-DSunOS5 -DSOLARIS" ;;
     995solaris2*)      LOCAL_CFLAGS=-DSOLARIS ;;
    995996lynxos*)        LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
    996997linux*)         LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
    997998                case "`uname -r`" in
  • doc/bash.1

    diff -Naur bash-3.2.orig/doc/bash.1 bash-3.2/doc/bash.1
    old new  
    79777977command in the same history entry.  This allows
    79787978easy re-editing of multi-line commands.
    79797979.TP 8
     7980.B compat31
     7981If set,
     7982.B bash
     7983changes its behavior to that of version 3.1 with respect to quoted
     7984arguments to the conditional command's =~ operator.
     7985.TP 8
    79807986.B dotglob
    79817987If set,
    79827988.B bash
  • doc/bashref.texi

    diff -Naur bash-3.2.orig/doc/bashref.texi bash-3.2/doc/bashref.texi
    old new  
    35983598command in the same history entry.  This allows
    35993599easy re-editing of multi-line commands.
    36003600
     3601@item compat31
     3602If set, Bash
     3603changes its behavior to that of version 3.1 with respect to quoted
     3604arguments to the conditional command's =~ operator.
     3605
    36013606@item dotglob
    36023607If set, Bash includes filenames beginning with a `.' in
    36033608the results of filename expansion.
  • execute_cmd.c

    diff -Naur bash-3.2.orig/execute_cmd.c bash-3.2/execute_cmd.c
    old new  
    11/* execute_cmd.c -- Execute a COMMAND structure. */
    22
    3 /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
     3/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
    44
    55   This file is part of GNU Bash, the Bourne Again SHell.
    66
     
    501501  volatile int last_pid;
    502502  volatile int save_line_number;
    503503
     504#if 0
    504505  if (command == 0 || breaking || continuing || read_but_dont_execute)
    505506    return (EXECUTION_SUCCESS);
     507#else
     508  if (breaking || continuing)
     509    return (last_command_exit_value);
     510  if (command == 0 || read_but_dont_execute)
     511    return (EXECUTION_SUCCESS);
     512#endif
    506513
    507514  QUIT;
    508515  run_pending_traps ();
     
    614621      cleanup_redirects (redirection_undo_list);
    615622      redirection_undo_list = (REDIRECT *)NULL;
    616623      dispose_exec_redirects ();
    617       return (EXECUTION_FAILURE);
     624      return (last_command_exit_value = EXECUTION_FAILURE);
    618625    }
    619626
    620627  if (redirection_undo_list)
     
    25462553      arg1 = cond_expand_word (cond->left->op, 0);
    25472554      if (arg1 == 0)
    25482555        arg1 = nullstr;
    2549       arg2 = cond_expand_word (cond->right->op, patmatch||rmatch);
     2556      arg2 = cond_expand_word (cond->right->op,
     2557                               (rmatch && shell_compatibility_level > 31) ? 2 : (patmatch ? 1 : 0));
    25502558      if (arg2 == 0)
    25512559        arg2 = nullstr;
    25522560
     
    30503058  if (command_line == 0)
    30513059    command_line = savestring (the_printed_command_except_trap);
    30523060
     3061#if defined (PROCESS_SUBSTITUTION)
     3062  if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0)
     3063    simple_command->flags &= ~CMD_NO_FORK;
     3064#endif
     3065
    30533066  execute_disk_command (words, simple_command->redirects, command_line,
    30543067                        pipe_in, pipe_out, async, fds_to_close,
    30553068                        simple_command->flags);
     
    38753888    shell_variables = shell_variables->down;
    38763889
    38773890  clear_unwind_protect_list (0);
     3891  /* XXX -- are there other things we should be resetting here? */
     3892  parse_and_execute_level = 0;          /* nothing left to restore it */
    38783893
    38793894  /* We're no longer inside a shell function. */
    38803895  variable_context = return_catch_flag = 0;
  • bash-3.2

    diff -Naur bash-3.2.orig/expr.c bash-3.2/expr.c
    old new  
    286286      free (expr_stack[expr_depth]);
    287287    }
    288288  free (expr_stack[expr_depth]);        /* free the allocated EXPR_CONTEXT */
     289
     290  noeval = 0;   /* XXX */
    289291}
    290292
    291293static void
     
    319321  procenv_t oevalbuf;
    320322
    321323  val = 0;
     324  noeval = 0;
    322325
    323326  FASTCOPY (evalbuf, oevalbuf, sizeof (evalbuf));
    324327
     
    517520          set_noeval = 1;
    518521          noeval++;
    519522        }
    520       val2 = explor ();
     523
     524      val2 = expcond ();
    521525      if (set_noeval)
    522526        noeval--;
    523527      rval = cval ? val1 : val2;
     
    929933      if (interactive_shell)
    930934        {
    931935          expr_unwind ();
     936          top_level_cleanup ();
    932937          jump_to_top_level (DISCARD);
    933938        }
    934939      else
  • findcmd.c

    diff -Naur bash-3.2.orig/findcmd.c bash-3.2/findcmd.c
    old new  
    308308  if (hashed_file && (posixly_correct || check_hashed_filenames))
    309309    {
    310310      st = file_status (hashed_file);
    311       if ((st ^ (FS_EXISTS | FS_EXECABLE)) != 0)
     311      if ((st & (FS_EXISTS|FS_EXECABLE)) != (FS_EXISTS|FS_EXECABLE))
    312312        {
    313313          phash_remove (pathname);
    314314          free (hashed_file);
  • bash-3.2

    diff -Naur bash-3.2.orig/jobs.c bash-3.2/jobs.c
    old new  
    250250static int job_exit_signal __P((int));
    251251static int set_job_status_and_cleanup __P((int));
    252252
     253static WAIT job_signal_status __P((int));
    253254static WAIT raw_job_exit_status __P((int));
    254255
    255256static void notify_of_job_status __P((void));
     
    783784  if (jobs[js.j_firstj] == 0)
    784785    {
    785786      old = js.j_firstj++;
     787      if (old >= js.j_jobslots)
     788        old = js.j_jobslots - 1;
    786789      while (js.j_firstj != old)
    787790        {
    788791          if (js.j_firstj >= js.j_jobslots)
    789792            js.j_firstj = 0;
    790           if (jobs[js.j_firstj])
     793          if (jobs[js.j_firstj] || js.j_firstj == old)  /* needed if old == 0 */
    791794            break;
    792795          js.j_firstj++;
    793796        }
     
    797800  if (jobs[js.j_lastj] == 0)
    798801    {
    799802      old = js.j_lastj--;
     803      if (old < 0)
     804        old = 0;
    800805      while (js.j_lastj != old)
    801806        {
    802807          if (js.j_lastj < 0)
    803808            js.j_lastj = js.j_jobslots - 1;
    804           if (jobs[js.j_lastj])
     809          if (jobs[js.j_lastj] || js.j_lastj == old)    /* needed if old == js.j_jobslots */
    805810            break;
    806811          js.j_lastj--;
    807812        }
     
    963968  reap_dead_jobs ();
    964969  realloc_jobs_list ();
    965970
    966   return (js.j_lastj);
     971#ifdef DEBUG
     972  itrace("compact_jobs_list: returning %d", (js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
     973#endif
     974
     975  return ((js.j_lastj || jobs[js.j_lastj]) ? js.j_lastj + 1 : 0);
    967976}
    968977
    969978/* Delete the job at INDEX from the job list.  Must be called
     
    984993  temp = jobs[job_index];
    985994  if (temp == 0)
    986995    return;
    987   if (job_index == js.j_current || job_index == js.j_previous)
    988     reset_current ();
    989996
    990997  if ((dflags & DEL_NOBGPID) == 0)
    991998    {
     
    10281035    js.j_firstj = js.j_lastj = 0;
    10291036  else if (jobs[js.j_firstj] == 0 || jobs[js.j_lastj] == 0)
    10301037    reset_job_indices ();
     1038
     1039  if (job_index == js.j_current || job_index == js.j_previous)
     1040    reset_current ();
    10311041}
    10321042
    10331043/* Must be called with SIGCHLD blocked. */
     
    22102220    return (EXECUTION_SUCCESS);
    22112221}
    22122222
     2223static WAIT
     2224job_signal_status (job)
     2225     int job;
     2226{
     2227  register PROCESS *p;
     2228  WAIT s;
     2229
     2230  p = jobs[job]->pipe;
     2231  do
     2232    {
     2233      s = p->status;
     2234      if (WIFSIGNALED(s) || WIFSTOPPED(s))
     2235        break;
     2236      p = p->next;
     2237    }
     2238  while (p != jobs[job]->pipe);
     2239
     2240  return s;
     2241}
     2242 
    22132243/* Return the exit status of the last process in the pipeline for job JOB.
    22142244   This is the exit status of the entire job. */
    22152245static WAIT
     
    22922322     to finish.  We don't want the shell to exit if an interrupt is
    22932323     received, only if one of the jobs run is killed via SIGINT.  If
    22942324     job control is not set, the job will be run in the same pgrp as
    2295      the shell, and the shell will see any signals the job gets. */
     2325     the shell, and the shell will see any signals the job gets.  In
     2326     fact, we want this set every time the waiting shell and the waited-
     2327     for process are in the same process group, including command
     2328     substitution. */
    22962329
    22972330  /* This is possibly a race condition -- should it go in stop_pipeline? */
    22982331  wait_sigint_received = 0;
    2299   if (job_control == 0)
     2332  if (job_control == 0 || (subshell_environment&SUBSHELL_COMSUB))
    23002333    {
    23012334      old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
    23022335      if (old_sigint_handler == SIG_IGN)
     
    24422475             to a signal.  We might want to change this later to just check
    24432476             the last process in the pipeline.  If no process exits due to a
    24442477             signal, S is left as the status of the last job in the pipeline. */
    2445           p = jobs[job]->pipe;
    2446           do
    2447             {
    2448               s = p->status;
    2449               if (WIFSIGNALED(s) || WIFSTOPPED(s))
    2450                 break;
    2451               p = p->next;
    2452             }
    2453           while (p != jobs[job]->pipe);
     2478          s = job_signal_status (job);
    24542479
    24552480          if (WIFSIGNALED (s) || WIFSTOPPED (s))
    24562481            {
     
    24842509                }
    24852510            }
    24862511        }
     2512      else if ((subshell_environment & SUBSHELL_COMSUB) && wait_sigint_received)
     2513        {
     2514          /* If waiting for a job in a subshell started to do command
     2515             substitution, simulate getting and being killed by the SIGINT to
     2516             pass the status back to our parent. */
     2517          s = job_signal_status (job);
     2518       
     2519          if (WIFSIGNALED (s) && WTERMSIG (s) == SIGINT && signal_is_trapped (SIGINT) == 0)
     2520            {
     2521              UNBLOCK_CHILD (oset);
     2522              restore_sigint_handler ();
     2523              old_sigint_handler = set_signal_handler (SIGINT, SIG_DFL);
     2524              if (old_sigint_handler == SIG_IGN)
     2525                restore_sigint_handler ();
     2526              else
     2527                kill (getpid (), SIGINT);
     2528            }
     2529        }
    24872530
    24882531      /* Moved here from set_job_status_and_cleanup, which is in the SIGCHLD
    24892532         signal handler path */
  • lib/readline/complete.c

    diff -Naur bash-3.2.orig/lib/readline/complete.c bash-3.2/lib/readline/complete.c
    old new  
    428428        return (1);
    429429      if (c == 'n' || c == 'N' || c == RUBOUT)
    430430        return (0);
    431       if (c == ABORT_CHAR)
     431      if (c == ABORT_CHAR || c < 0)
    432432        _rl_abort_internal ();
    433433      if (for_pager && (c == NEWLINE || c == RETURN))
    434434        return (2);
  • lib/readline/display.c

    diff -Naur bash-3.2.orig/lib/readline/display.c bash-3.2/lib/readline/display.c
    old new  
    391391      t = ++p;
    392392      local_prompt = expand_prompt (p, &prompt_visible_length,
    393393                                       &prompt_last_invisible,
    394                                        (int *)NULL,
     394                                       &prompt_invis_chars_first_line,
    395395                                       &prompt_physical_chars);
    396396      c = *t; *t = '\0';
    397397      /* The portion of the prompt string up to and including the
    398398         final newline is now null-terminated. */
    399399      local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
    400400                                                   (int *)NULL,
    401                                                    &prompt_invis_chars_first_line,
     401                                                   (int *)NULL,
    402402                                                   (int *)NULL);
    403403      *t = c;
    404404      local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
     
    561561      wrap_offset = prompt_invis_chars_first_line = 0;
    562562    }
    563563
     564#if defined (HANDLE_MULTIBYTE)
     565#define CHECK_INV_LBREAKS() \
     566      do { \
     567        if (newlines >= (inv_lbsize - 2)) \
     568          { \
     569            inv_lbsize *= 2; \
     570            inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
     571            _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
     572          } \
     573      } while (0)
     574#else
    564575#define CHECK_INV_LBREAKS() \
    565576      do { \
    566577        if (newlines >= (inv_lbsize - 2)) \
     
    569580            inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
    570581          } \
    571582      } while (0)
     583#endif /* HANDLE_MULTIBYTE */
    572584
    573585#if defined (HANDLE_MULTIBYTE)   
    574586#define CHECK_LPOS() \
     
    898910             second and subsequent lines start at inv_lbreaks[N], offset by
    899911             OFFSET (which has already been calculated above).  */
    900912
     913#define INVIS_FIRST()   (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
     914#define WRAP_OFFSET(line, offset)  ((line == 0) \
     915                                        ? (offset ? INVIS_FIRST() : 0) \
     916                                        : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
    901917#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
    902918#define VIS_LLEN(l)     ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
    903919#define INV_LLEN(l)     (inv_lbreaks[l+1] - inv_lbreaks[l])
     
    932948                  _rl_last_c_pos != o_cpos &&
    933949                  _rl_last_c_pos > wrap_offset &&
    934950                  o_cpos < prompt_last_invisible)
    935                 _rl_last_c_pos -= wrap_offset;
     951                _rl_last_c_pos -= prompt_invis_chars_first_line;        /* XXX - was wrap_offset */
     952              else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
     953                        (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
     954                        cpos_adjusted == 0 &&
     955                        _rl_last_c_pos != o_cpos &&
     956                        _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
     957                _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
    936958                 
    937959              /* If this is the line with the prompt, we might need to
    938960                 compensate for invisible characters in the new line. Do
     
    10361058                tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
    10371059              else
    10381060                tx = nleft;
    1039               if (_rl_last_c_pos > tx)
     1061              if (tx >= 0 && _rl_last_c_pos > tx)
    10401062                {
    10411063                  _rl_backspace (_rl_last_c_pos - tx);  /* XXX */
    10421064                  _rl_last_c_pos = tx;
     
    11921214     int current_line, omax, nmax, inv_botlin;
    11931215{
    11941216  register char *ofd, *ols, *oe, *nfd, *nls, *ne;
    1195   int temp, lendiff, wsatend, od, nd;
     1217  int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
    11961218  int current_invis_chars;
    11971219  int col_lendiff, col_temp;
    11981220#if defined (HANDLE_MULTIBYTE)
     
    12081230  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    12091231    temp = _rl_last_c_pos;
    12101232  else
    1211     temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
     1233    temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
    12121234  if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
    12131235        && _rl_last_v_pos == current_line - 1)
    12141236    {
     
    14531475        _rl_last_c_pos = lendiff;
    14541476    }
    14551477
     1478  o_cpos = _rl_last_c_pos;
     1479
    14561480  /* When this function returns, _rl_last_c_pos is correct, and an absolute
    14571481     cursor postion in multibyte mode, but a buffer index when not in a
    14581482     multibyte locale. */
     
    14621486  /* We need to indicate that the cursor position is correct in the presence of
    14631487     invisible characters in the prompt string.  Let's see if setting this when
    14641488     we make sure we're at the end of the drawn prompt string works. */
    1465   if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars)
     1489  if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 &&
     1490      (_rl_last_c_pos > 0 || o_cpos > 0) &&
     1491      _rl_last_c_pos == prompt_physical_chars)
    14661492    cpos_adjusted = 1;
    14671493#endif
    14681494#endif
     
    15061532    {
    15071533      /* Non-zero if we're increasing the number of lines. */
    15081534      int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
     1535      /* If col_lendiff is > 0, implying that the new string takes up more
     1536         screen real estate than the old, but lendiff is < 0, meaning that it
     1537         takes fewer bytes, we need to just output the characters starting
     1538         from the first difference.  These will overwrite what is on the
     1539         display, so there's no reason to do a smart update.  This can really
     1540         only happen in a multibyte environment. */
     1541      if (lendiff < 0)
     1542        {
     1543          _rl_output_some_chars (nfd, temp);
     1544          _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
     1545          /* If nfd begins before any invisible characters in the prompt,
     1546             adjust _rl_last_c_pos to account for wrap_offset and set
     1547             cpos_adjusted to let the caller know. */
     1548          if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
     1549            {
     1550              _rl_last_c_pos -= wrap_offset;
     1551              cpos_adjusted = 1;
     1552            }
     1553          return;
     1554        }
    15091555      /* Sometimes it is cheaper to print the characters rather than
    15101556         use the terminal's capabilities.  If we're growing the number
    15111557         of lines, make sure we actually cause the new line to wrap
    15121558         around on auto-wrapping terminals. */
    1513       if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
     1559      else if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
    15141560        {
    15151561          /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
    15161562             _rl_horizontal_scroll_mode == 1, inserting the characters with
     
    15331579            }
    15341580          else
    15351581            {
    1536               /* We have horizontal scrolling and we are not inserting at
    1537                  the end.  We have invisible characters in this line.  This
    1538                  is a dumb update. */
    15391582              _rl_output_some_chars (nfd, temp);
    15401583              _rl_last_c_pos += col_temp;
     1584              /* If nfd begins before any invisible characters in the prompt,
     1585                 adjust _rl_last_c_pos to account for wrap_offset and set
     1586                 cpos_adjusted to let the caller know. */
     1587              if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
     1588                {
     1589                  _rl_last_c_pos -= wrap_offset;
     1590                  cpos_adjusted = 1;
     1591                }
    15411592              return;
    15421593            }
    15431594          /* Copy (new) chars to screen from first diff to last match. */
     
    15451596          if ((temp - lendiff) > 0)
    15461597            {
    15471598              _rl_output_some_chars (nfd + lendiff, temp - lendiff);
    1548 #if 1
    15491599             /* XXX -- this bears closer inspection.  Fixes a redisplay bug
    15501600                reported against bash-3.0-alpha by Andreas Schwab involving
    15511601                multibyte characters and prompt strings with invisible
    15521602                characters, but was previously disabled. */
    1553               _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
    1554 #else
    1555               _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
    1556 #endif
     1603              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1604                twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
     1605              else
     1606                twidth = temp - lendiff;
     1607              _rl_last_c_pos += twidth;
    15571608            }
    15581609        }
    15591610      else
     
    15861637          temp = nls - nfd;
    15871638          if (temp > 0)
    15881639            {
     1640              /* If nfd begins at the prompt, or before the invisible
     1641                 characters in the prompt, we need to adjust _rl_last_c_pos
     1642                 in a multibyte locale to account for the wrap offset and
     1643                 set cpos_adjusted accordingly. */
    15891644              _rl_output_some_chars (nfd, temp);
    1590               _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
     1645              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1646                {
     1647                  _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
     1648                  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
     1649                    {
     1650                      _rl_last_c_pos -= wrap_offset;
     1651                      cpos_adjusted = 1;
     1652                    }
     1653                }
     1654              else
     1655                _rl_last_c_pos += temp;
    15911656            }
    15921657        }
    15931658      /* Otherwise, print over the existing material. */
     
    15951660        {
    15961661          if (temp > 0)
    15971662            {
     1663              /* If nfd begins at the prompt, or before the invisible
     1664                 characters in the prompt, we need to adjust _rl_last_c_pos
     1665                 in a multibyte locale to account for the wrap offset and
     1666                 set cpos_adjusted accordingly. */
    15981667              _rl_output_some_chars (nfd, temp);
    15991668              _rl_last_c_pos += col_temp;               /* XXX */
     1669              if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     1670                {
     1671                  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
     1672                    {
     1673                      _rl_last_c_pos -= wrap_offset;
     1674                      cpos_adjusted = 1;
     1675                    }
     1676                }
    16001677            }
    16011678          lendiff = (oe - old) - (ne - new);
    16021679          if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     
    17211798  int woff;                     /* number of invisible chars on current line */
    17221799  int cpos, dpos;               /* current and desired cursor positions */
    17231800
    1724   woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
     1801  woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
    17251802  cpos = _rl_last_c_pos;
    17261803#if defined (HANDLE_MULTIBYTE)
    17271804  /* If we have multibyte characters, NEW is indexed by the buffer point in
     
    17321809  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    17331810    {
    17341811      dpos = _rl_col_width (data, 0, new);
    1735       if (dpos > prompt_last_invisible)         /* XXX - don't use woff here */
     1812      /* Use NEW when comparing against the last invisible character in the
     1813         prompt string, since they're both buffer indices and DPOS is a
     1814         desired display position. */
     1815      if ((new > prompt_last_invisible) ||              /* XXX - don't use woff here */
     1816          (prompt_physical_chars > _rl_screenwidth &&
     1817           _rl_last_v_pos == prompt_last_screen_line &&
     1818           wrap_offset != woff &&
     1819           new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))
    17361820        {
    17371821          dpos -= woff;
    17381822          /* Since this will be assigned to _rl_last_c_pos at the end (more
     
    23802464
    23812465  if (end <= start)
    23822466    return 0;
     2467  if (MB_CUR_MAX == 1 || rl_byte_oriented)
     2468    return (end - start);
    23832469
    23842470  memset (&ps, 0, sizeof (mbstate_t));
    23852471
  • lib/readline/input.c

    diff -Naur bash-3.2.orig/lib/readline/input.c bash-3.2/lib/readline/input.c
    old new  
    133133    return (0);
    134134
    135135  *key = ibuffer[pop_index++];
    136 
     136#if 0
    137137  if (pop_index >= ibuffer_len)
     138#else
     139  if (pop_index > ibuffer_len)
     140#endif
    138141    pop_index = 0;
    139142
    140143  return (1);
     
    151154    {
    152155      pop_index--;
    153156      if (pop_index < 0)
    154         pop_index = ibuffer_len - 1;
     157        pop_index = ibuffer_len;
    155158      ibuffer[pop_index] = key;
    156159      return (1);
    157160    }
     
    250253      while (chars_avail--)
    251254        {
    252255          k = (*rl_getc_function) (rl_instream);
    253           rl_stuff_char (k);
     256          if (rl_stuff_char (k) == 0)
     257            break;                      /* some problem; no more room */
    254258          if (k == NEWLINE || k == RETURN)
    255259            break;
    256260        }
     
    373377      RL_SETSTATE (RL_STATE_INPUTPENDING);
    374378    }
    375379  ibuffer[push_index++] = key;
     380#if 0
    376381  if (push_index >= ibuffer_len)
     382#else
     383  if (push_index > ibuffer_len)
     384#endif
    377385    push_index = 0;
    378386
    379387  return 1;
     
    513521     char *mbchar;
    514522     int size;
    515523{
    516   int mb_len = 0;
     524  int mb_len, c;
    517525  size_t mbchar_bytes_length;
    518526  wchar_t wc;
    519527  mbstate_t ps, ps_back;
    520528
    521529  memset(&ps, 0, sizeof (mbstate_t));
    522530  memset(&ps_back, 0, sizeof (mbstate_t));
    523  
     531
     532  mb_len = 0; 
    524533  while (mb_len < size)
    525534    {
    526535      RL_SETSTATE(RL_STATE_MOREINPUT);
    527       mbchar[mb_len++] = rl_read_key ();
     536      c = rl_read_key ();
    528537      RL_UNSETSTATE(RL_STATE_MOREINPUT);
    529538
     539      if (c < 0)
     540        break;
     541
     542      mbchar[mb_len++] = c;
     543
    530544      mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
    531545      if (mbchar_bytes_length == (size_t)(-1))
    532546        break;          /* invalid byte sequence for the current locale */
     
    564578
    565579  c = first;
    566580  memset (mb, 0, mlen);
    567   for (i = 0; i < mlen; i++)
     581  for (i = 0; c >= 0 && i < mlen; i++)
    568582    {
    569583      mb[i] = (char)c;
    570584      memset (&ps, 0, sizeof (mbstate_t));
  • lib/readline/isearch.c

    diff -Naur bash-3.2.orig/lib/readline/isearch.c bash-3.2/lib/readline/isearch.c
    old new  
    327327  rl_command_func_t *f;
    328328
    329329  f = (rl_command_func_t *)NULL;
    330  
    331  /* Translate the keys we do something with to opcodes. */
     330
     331  if (c < 0)
     332    {
     333      cxt->sflags |= SF_FAILED;
     334      cxt->history_pos = cxt->last_found_line;
     335      return -1;
     336    }
     337
     338  /* Translate the keys we do something with to opcodes. */
    332339  if (c >= 0 && _rl_keymap[c].type == ISFUNC)
    333340    {
    334341      f = _rl_keymap[c].function;
  • lib/readline/misc.c

    diff -Naur bash-3.2.orig/lib/readline/misc.c bash-3.2/lib/readline/misc.c
    old new  
    146146          rl_restore_prompt ();
    147147          rl_clear_message ();
    148148          RL_UNSETSTATE(RL_STATE_NUMERICARG);
     149          if (key < 0)
     150            return -1;
    149151          return (_rl_dispatch (key, _rl_keymap));
    150152        }
    151153    }
  • lib/readline/readline.c

    diff -Naur bash-3.2.orig/lib/readline/readline.c bash-3.2/lib/readline/readline.c
    old new  
    645645  if ((cxt->flags & KSEQ_DISPATCHED) == 0)
    646646    {
    647647      nkey = _rl_subseq_getchar (cxt->okey);
     648      if (nkey < 0)
     649        {
     650          _rl_abort_internal ();
     651          return -1;
     652        }
    648653      r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
    649654      cxt->flags |= KSEQ_DISPATCHED;
    650655    }
  • lib/readline/text.c

    diff -Naur bash-3.2.orig/lib/readline/text.c bash-3.2/lib/readline/text.c
    old new  
    857857  c = rl_read_key ();
    858858  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    859859
     860  if (c < 0)
     861    return -1;
     862
    860863#if defined (HANDLE_SIGNALS)
    861864  if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
    862865    _rl_restore_tty_signals ();
     
    15201523
    15211524  mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
    15221525
     1526  if (mb_len <= 0)
     1527    return -1;
     1528
    15231529  if (count < 0)
    15241530    return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
    15251531  else
     
    15361542  c = rl_read_key ();
    15371543  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    15381544
     1545  if (c < 0)
     1546    return -1;
     1547
    15391548  if (count < 0)
    15401549    return (_rl_char_search_internal (-count, bdir, c));
    15411550  else
  • lib/readline/vi_mode.c

    diff -Naur bash-3.2.orig/lib/readline/vi_mode.c bash-3.2/lib/readline/vi_mode.c
    old new  
    886886  RL_SETSTATE(RL_STATE_MOREINPUT);
    887887  c = rl_read_key ();
    888888  RL_UNSETSTATE(RL_STATE_MOREINPUT);
     889
     890  if (c < 0)
     891    {
     892      *nextkey = 0;
     893      return -1;
     894    }
     895
    889896  *nextkey = c;
    890897
    891898  if (!member (c, vi_motion))
     
    902909          RL_SETSTATE(RL_STATE_MOREINPUT);
    903910          c = rl_read_key ();   /* real command */
    904911          RL_UNSETSTATE(RL_STATE_MOREINPUT);
     912          if (c < 0)
     913            {
     914              *nextkey = 0;
     915              return -1;
     916            }
    905917          *nextkey = c;
    906918        }
    907919      else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
     
    12241236_rl_vi_callback_char_search (data)
    12251237     _rl_callback_generic_arg *data;
    12261238{
     1239  int c;
    12271240#if defined (HANDLE_MULTIBYTE)
    1228   _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1241  c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
    12291242#else
    12301243  RL_SETSTATE(RL_STATE_MOREINPUT);
    1231   _rl_vi_last_search_char = rl_read_key ();
     1244  c = rl_read_key ();
    12321245  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    12331246#endif
    12341247
     1248  if (c <= 0)
     1249    return -1;
     1250
     1251#if !defined (HANDLE_MULTIBYTE)
     1252  _rl_vi_last_search_char = c;
     1253#endif
     1254
    12351255  _rl_callback_func = 0;
    12361256  _rl_want_redisplay = 1;
    12371257
     
    12471267rl_vi_char_search (count, key)
    12481268     int count, key;
    12491269{
     1270  int c;
    12501271#if defined (HANDLE_MULTIBYTE)
    12511272  static char *target;
    12521273  static int tlen;
     
    12931314      else
    12941315        {
    12951316#if defined (HANDLE_MULTIBYTE)
    1296           _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1317          c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
     1318          if (c <= 0)
     1319            return -1;
     1320          _rl_vi_last_search_mblen = c;
    12971321#else
    12981322          RL_SETSTATE(RL_STATE_MOREINPUT);
    1299           _rl_vi_last_search_char = rl_read_key ();
     1323          c = rl_read_key ();
    13001324          RL_UNSETSTATE(RL_STATE_MOREINPUT);
     1325          if (c < 0)
     1326            return -1;
     1327          _rl_vi_last_search_char = c;
    13011328#endif
    13021329        }
    13031330    }
     
    14671494  c = rl_read_key ();
    14681495  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    14691496
     1497  if (c < 0)
     1498    return -1;
     1499
    14701500#if defined (HANDLE_MULTIBYTE)
    14711501  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
    14721502    c = _rl_read_mbstring (c, mb, mlen);
     
    14851515
    14861516  _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
    14871517
     1518  if (c < 0)
     1519    return -1;
     1520
    14881521  _rl_callback_func = 0;
    14891522  _rl_want_redisplay = 1;
    14901523
     
    15161549  else
    15171550    _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
    15181551
     1552  if (c < 0)
     1553    return -1;
     1554
    15191555  return (_rl_vi_change_char (count, c, mb));
    15201556}
    15211557
     
    16501686  ch = rl_read_key ();
    16511687  RL_UNSETSTATE(RL_STATE_MOREINPUT);
    16521688
    1653   if (ch < 'a' || ch > 'z')
     1689  if (ch < 0 || ch < 'a' || ch > 'z')   /* make test against 0 explicit */
    16541690    {
    16551691      rl_ding ();
    16561692      return -1;
     
    17021738      rl_point = rl_mark;
    17031739      return 0;
    17041740    }
    1705   else if (ch < 'a' || ch > 'z')
     1741  else if (ch < 0 || ch < 'a' || ch > 'z')      /* make test against 0 explicit */
    17061742    {
    17071743      rl_ding ();
    17081744      return -1;
  • lib/sh/getcwd.c

    diff -Naur bash-3.2.orig/lib/sh/getcwd.c bash-3.2/lib/sh/getcwd.c
    old new  
    251251
    252252  {
    253253    size_t len = pathbuf + pathsize - pathp;
     254    if (buf == NULL && size <= 0)
     255      size = len;
     256
     257    if ((size_t) size < len)
     258      {
     259        errno = ERANGE;
     260        goto lose2;
     261      }
    254262    if (buf == NULL)
    255263      {
    256         if (len < (size_t) size)
    257           len = size;
    258         buf = (char *) malloc (len);
     264        buf = (char *) malloc (size);
    259265        if (buf == NULL)
    260266          goto lose2;
    261267      }
    262     else if ((size_t) size < len)
    263       {
    264         errno = ERANGE;
    265         goto lose2;
    266       }
     268
    267269    (void) memcpy((PTR_T) buf, (PTR_T) pathp, len);
    268270  }
    269271
  • lib/sh/snprintf.c

    diff -Naur bash-3.2.orig/lib/sh/snprintf.c bash-3.2/lib/sh/snprintf.c
    old new  
    471471          10^x ~= r
    472472 * log_10(200) = 2;
    473473 * log_10(250) = 2;
     474 *
     475 * NOTE: do not call this with r == 0 -- an infinite loop results.
    474476 */
    475477static int
    476478log_10(r)
     
    576578    {
    577579      integral_part[0] = '0';
    578580      integral_part[1] = '\0';
    579       fraction_part[0] = '0';
    580       fraction_part[1] = '\0';
     581      /* The fractional part has to take the precision into account */
     582      for (ch = 0; ch < precision-1; ch++)
     583        fraction_part[ch] = '0';
     584      fraction_part[ch] = '0';
     585      fraction_part[ch+1] = '\0';
    581586      if (fract)
    582587        *fract = fraction_part;
    583588      return integral_part;
     
    663668    p->flags &= ~PF_ZEROPAD;
    664669
    665670  sd = d;       /* signed for ' ' padding in base 10 */
    666   flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
     671  flags = 0;
     672  flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
    667673  if (*p->pf == 'X')
    668674    flags |= FL_HEXUPPER;
    669675
     
    733739    p->flags &= ~PF_ZEROPAD;
    734740
    735741  sd = d;       /* signed for ' ' padding in base 10 */
    736   flags = (*p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
     742  flags = (*p->pf == 'x' || *p->pf == 'X' || *p->pf == 'o' || *p->pf == 'u' || *p->pf == 'U') ? FL_UNSIGNED : 0;
    737743  if (*p->pf == 'X')
    738744    flags |= FL_HEXUPPER;
    739745
     
    805811      PUT_CHAR(*tmp, p);
    806812      tmp++;
    807813    }
     814
    808815  PAD_LEFT(p);
    809816}
    810817
     
    972979  if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
    973980    tmp = t;
    974981
     982  if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
     983    {
     984      /* smash the trailing zeros unless altform */
     985      for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
     986        tmp2[i] = '\0';
     987      if (tmp2[0] == '\0')
     988        p->precision = 0;
     989    }
     990
    975991  /* calculate the padding. 1 for the dot */
    976992  p->width = p->width -
    977993            ((d > 0. && p->justify == RIGHT) ? 1:0) -
    978994            ((p->flags & PF_SPACE) ? 1:0) -
    979             strlen(tmp) - p->precision - 1;
     995            strlen(tmp) - p->precision -
     996            ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0);   /* radix char */
    980997  PAD_RIGHT(p); 
    981998  PUT_PLUS(d, p, 0.);
    982999  PUT_SPACE(d, p, 0.);
     
    9911008  if (p->precision != 0 || (p->flags & PF_ALTFORM))
    9921009    PUT_CHAR(decpoint, p);  /* put the '.' */
    9931010
    994   if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
    995     /* smash the trailing zeros unless altform */
    996     for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
    997       tmp2[i] = '\0';
    998 
    9991011  for (; *tmp2; tmp2++)
    10001012    PUT_CHAR(*tmp2, p); /* the fraction */
    10011013 
     
    10111023  char *tmp, *tmp2;
    10121024  int j, i;
    10131025
    1014   if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
     1026  if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
    10151027    return;     /* already printed nan or inf */
    10161028
    10171029  GETLOCALEDATA(decpoint, thoussep, grouping);
    10181030  DEF_PREC(p);
    1019   j = log_10(d);
    1020   d = d / pow_10(j);  /* get the Mantissa */
    1021   d = ROUND(d, p);               
     1031  if (d == 0.)
     1032    j = 0;
     1033  else
     1034    {
     1035      j = log_10(d);
     1036      d = d / pow_10(j);  /* get the Mantissa */
     1037      d = ROUND(d, p);           
     1038    }
    10221039  tmp = dtoa(d, p->precision, &tmp2);
    10231040
    10241041  /* 1 for unit, 1 for the '.', 1 for 'e|E',
     
    10761093       PUT_CHAR(*tmp, p);
    10771094       tmp++;
    10781095     }
     1096
    10791097   PAD_LEFT(p);
    10801098}
    10811099#endif
     
    13581376                STAR_ARGS(data);
    13591377                DEF_PREC(data);
    13601378                d = GETDOUBLE(data);
    1361                 i = log_10(d);
     1379                i = (d != 0.) ? log_10(d) : -1;
    13621380                /*
    13631381                 * for '%g|%G' ANSI: use f if exponent
    13641382                 * is in the range or [-4,p] exclusively
  • parse.y

    diff -Naur bash-3.2.orig/parse.y bash-3.2/parse.y
    old new  
    10291029#define PST_CMDTOKEN    0x1000          /* command token OK - unused */
    10301030#define PST_COMPASSIGN  0x2000          /* parsing x=(...) compound assignment */
    10311031#define PST_ASSIGNOK    0x4000          /* assignment statement ok in this context */
     1032#define PST_REGEXP      0x8000          /* parsing an ERE/BRE as a single word */
    10321033
    10331034/* Initial size to allocate for tokens, and the
    10341035   amount to grow them by. */
     
    25912592      return (character);
    25922593    }
    25932594
     2595  if (parser_state & PST_REGEXP)
     2596    goto tokword;
     2597
    25942598  /* Shell meta-characters. */
    25952599  if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
    25962600    {
     
    26982702  if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
    26992703    return (character);
    27002704
     2705tokword:
    27012706  /* Okay, if we got this far, we have to read a word.  Read one,
    27022707     and then check it against the known ones. */
    27032708  result = read_token_word (character);
     
    27352740/* itrace("parse_matched_pair: open = %c close = %c", open, close); */
    27362741  count = 1;
    27372742  pass_next_character = backq_backslash = was_dollar = in_comment = 0;
    2738   check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
     2743  check_comment = (flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
    27392744
    27402745  /* RFLAGS is the set of flags we want to pass to recursive calls. */
    27412746  rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
     
    32023207      if (tok == WORD && test_binop (yylval.word->word))
    32033208        op = yylval.word;
    32043209#if defined (COND_REGEXP)
    3205       else if (tok == WORD && STREQ (yylval.word->word,"=~"))
    3206         op = yylval.word;
     3210      else if (tok == WORD && STREQ (yylval.word->word, "=~"))
     3211        {
     3212          op = yylval.word;
     3213          parser_state |= PST_REGEXP;
     3214        }
    32073215#endif
    32083216      else if (tok == '<' || tok == '>')
    32093217        op = make_word_from_token (tok);  /* ( */
     
    32343242
    32353243      /* rhs */
    32363244      tok = read_token (READ);
     3245      parser_state &= ~PST_REGEXP;
    32373246      if (tok == WORD)
    32383247        {
    32393248          tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
     
    33673376      if (pass_next_character)
    33683377        {
    33693378          pass_next_character = 0;
    3370           goto got_character;
     3379          goto got_escaped_character;
    33713380        }
    33723381
    33733382      cd = current_delimiter (dstack);
     
    34193428          goto next_character;
    34203429        }
    34213430
     3431#ifdef COND_REGEXP
     3432      /* When parsing a regexp as a single word inside a conditional command,
     3433         we need to special-case characters special to both the shell and
     3434         regular expressions.  Right now, that is only '(' and '|'. */ /*)*/
     3435      if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|'))          /*)*/
     3436        {
     3437          if (character == '|')
     3438            goto got_character;
     3439
     3440          push_delimiter (dstack, character);
     3441          ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
     3442          pop_delimiter (dstack);
     3443          if (ttok == &matched_pair_error)
     3444            return -1;          /* Bail immediately. */
     3445          RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
     3446                                  token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
     3447          token[token_index++] = character;
     3448          strcpy (token + token_index, ttok);
     3449          token_index += ttoklen;
     3450          FREE (ttok);
     3451          dollar_present = all_digit_token = 0;
     3452          goto next_character;
     3453        }
     3454#endif /* COND_REGEXP */
     3455
    34223456#ifdef EXTENDED_GLOB
    34233457      /* Parse a ksh-style extended pattern matching specification. */
    3424       if (extended_glob && PATTERN_CHAR (character))
     3458      if MBTEST(extended_glob && PATTERN_CHAR (character))
    34253459        {
    34263460          peek_char = shell_getc (1);
    34273461          if MBTEST(peek_char == '(')           /* ) */
     
    36163650
    36173651    got_character:
    36183652
    3619       all_digit_token &= DIGIT (character);
    3620       dollar_present |= character == '$';
    3621 
    36223653      if (character == CTLESC || character == CTLNUL)
    36233654        token[token_index++] = CTLESC;
    36243655
     3656    got_escaped_character:
     3657
     3658      all_digit_token &= DIGIT (character);
     3659      dollar_present |= character == '$';
     3660
    36253661      token[token_index++] = character;
    36263662
    36273663      RESIZE_MALLOCED_BUFFER (token, token_index, 1, token_buffer_size,
     
    43304366  if (promptvars || posixly_correct)
    43314367    {
    43324368      last_exit_value = last_command_exit_value;
    4333       list = expand_prompt_string (result, Q_DOUBLE_QUOTES);
     4369      list = expand_prompt_string (result, Q_DOUBLE_QUOTES, 0);
    43344370      free (result);
    43354371      result = string_list (list);
    43364372      dispose_words (list);
  • patchlevel.h

    diff -Naur bash-3.2.orig/patchlevel.h bash-3.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 48
    2929
    3030#endif /* _PATCHLEVEL_H_ */
  • pathexp.c

    diff -Naur bash-3.2.orig/pathexp.c bash-3.2/pathexp.c
    old new  
    11/* pathexp.c -- The shell interface to the globbing library. */
    22
    3 /* Copyright (C) 1995-2002 Free Software Foundation, Inc.
     3/* Copyright (C) 1995-2007 Free Software Foundation, Inc.
    44
    55   This file is part of GNU Bash, the Bourne Again SHell.
    66
     
    110110  return (0);
    111111}
    112112
     113/* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
     114   be quoted to match itself. */
     115static inline int
     116ere_char (c)
     117     int c;
     118{
     119  switch (c)
     120    {
     121    case '.':
     122    case '[':
     123    case '\\':
     124    case '(':
     125    case ')':
     126    case '*':
     127    case '+':
     128    case '?':
     129    case '{':
     130    case '|':
     131    case '^':
     132    case '$':
     133      return 1;
     134    default:
     135      return 0;
     136    }
     137  return (0);
     138}
     139
    113140/* PATHNAME can contain characters prefixed by CTLESC; this indicates
    114141   that the character is to be quoted.  We quote it here in the style
    115142   that the glob library recognizes.  If flags includes QGLOB_CVTNULL,
     
    142169        {
    143170          if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
    144171            continue;
     172          if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
     173            continue;
    145174          temp[j++] = '\\';
    146175          i++;
    147176          if (pathname[i] == '\0')
  • pathexp.h

    diff -Naur bash-3.2.orig/pathexp.h bash-3.2/pathexp.h
    old new  
    11/* pathexp.h -- The shell interface to the globbing library. */
    22
    3 /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
     3/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
    44
    55   This file is part of GNU Bash, the Bourne Again SHell.
    66
     
    3232/* Flag values for quote_string_for_globbing */
    3333#define QGLOB_CVTNULL   0x01    /* convert QUOTED_NULL strings to '\0' */
    3434#define QGLOB_FILENAME  0x02    /* do correct quoting for matching filenames */
     35#define QGLOB_REGEXP    0x04    /* quote an ERE for regcomp/regexec */
    3536
    3637#if defined (EXTENDED_GLOB)
    3738/* Flags to OR with other flag args to strmatch() to enabled the extended
  • po/ru.po

    diff -Naur bash-3.2.orig/po/ru.po bash-3.2/po/ru.po
    old new  
    1212"Last-Translator: Evgeniy Dushistov <dushistov@mail.ru>\n"
    1313"Language-Team: Russian <ru@li.org>\n"
    1414"MIME-Version: 1.0\n"
    15 "Content-Type: text/plain; charset=UTF-8\n"
     15"Content-Type: text/plain; charset=KOI8-R\n"
    1616"Content-Transfer-Encoding: 8bit\n"
    1717"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
    1818
  • shell.h

    diff -Naur bash-3.2.orig/shell.h bash-3.2/shell.h
    old new  
    8989extern int executing, login_shell;
    9090extern int interactive, interactive_shell;
    9191extern int startup_state;
     92extern int shell_compatibility_level;
    9293
    9394/* Structure to pass around that holds a bitmap of file descriptors
    9495   to close, and the size of that structure.  Used in execute_cmd.c. */
  • bash-3.2

    diff -Naur bash-3.2.orig/sig.c bash-3.2/sig.c
    old new  
    350350#undef XSIG
    351351#undef XHANDLER
    352352
     353/* Run some of the cleanups that should be performed when we run
     354   jump_to_top_level from a builtin command context.  XXX - might want to
     355   also call reset_parser here. */
     356void
     357top_level_cleanup ()
     358{
     359  /* Clean up string parser environment. */
     360  while (parse_and_execute_level)
     361    parse_and_execute_cleanup ();
     362
     363#if defined (PROCESS_SUBSTITUTION)
     364  unlink_fifo_list ();
     365#endif /* PROCESS_SUBSTITUTION */
     366
     367  run_unwind_protects ();
     368  loop_level = continuing = breaking = 0;
     369  return_catch_flag = 0;
     370}
     371
    353372/* What to do when we've been interrupted, and it is safe to handle it. */
    354373void
    355374throw_to_top_level ()
  • bash-3.2

    diff -Naur bash-3.2.orig/sig.h bash-3.2/sig.h
    old new  
    121121extern void initialize_signals __P((int));
    122122extern void initialize_terminating_signals __P((void));
    123123extern void reset_terminating_signals __P((void));
     124extern void top_level_cleanup __P((void));
    124125extern void throw_to_top_level __P((void));
    125126extern void jump_to_top_level __P((int)) __attribute__((__noreturn__));
    126127
  • subst.c

    diff -Naur bash-3.2.orig/subst.c bash-3.2/subst.c
    old new  
    44/* ``Have a little faith, there's magic in the night.  You ain't a
    55     beauty, but, hey, you're alright.'' */
    66
    7 /* Copyright (C) 1987-2006 Free Software Foundation, Inc.
     7/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
    88
    99   This file is part of GNU Bash, the Bourne Again SHell.
    1010
     
    137137/* Extern functions and variables from different files. */
    138138extern int last_command_exit_value, last_command_exit_signal;
    139139extern int subshell_environment;
    140 extern int subshell_level;
     140extern int subshell_level, parse_and_execute_level;
    141141extern int eof_encountered;
    142142extern int return_catch_flag, return_catch_value;
    143143extern pid_t dollar_dollar_pid;
     
    12781278    {
    12791279      if (no_longjmp_on_fatal_error == 0)
    12801280        {                       /* { */
    1281           report_error ("bad substitution: no closing `%s' in %s", "}", string);
     1281          report_error (_("bad substitution: no closing `%s' in %s"), "}", string);
    12821282          last_command_exit_value = EXECUTION_FAILURE;
    12831283          exp_jump_to_top_level (DISCARD);
    12841284        }
     
    18871887  sep[1] = '\0';
    18881888#endif
    18891889
     1890  /* XXX -- why call quote_list if ifs == 0?  we can get away without doing
     1891     it now that quote_escapes quotes spaces */
     1892#if 0
    18901893  tlist = ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (ifs && *ifs == 0))
     1894#else
     1895  tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
     1896#endif
    18911897                ? quote_list (list)
    18921898                : list_quote_escapes (list);
    18931899
     
    26462652
    26472653/* This needs better error handling. */
    26482654/* Expand W for use as an argument to a unary or binary operator in a
    2649    [[...]] expression.  If SPECIAL is nonzero, this is the rhs argument
     2655   [[...]] expression.  If SPECIAL is 1, this is the rhs argument
    26502656   to the != or == operator, and should be treated as a pattern.  In
    2651    this case, we quote the string specially for the globbing code.  The
    2652    caller is responsible for removing the backslashes if the unquoted
    2653    words is needed later. */   
     2657   this case, we quote the string specially for the globbing code.  If
     2658   SPECIAL is 2, this is an rhs argument for the =~ operator, and should
     2659   be quoted appropriately for regcomp/regexec.  The caller is responsible
     2660   for removing the backslashes if the unquoted word is needed later. */   
    26542661char *
    26552662cond_expand_word (w, special)
    26562663     WORD_DESC *w;
     
    26582665{
    26592666  char *r, *p;
    26602667  WORD_LIST *l;
     2668  int qflags;
    26612669
    26622670  if (w->word == 0 || w->word[0] == '\0')
    26632671    return ((char *)NULL);
     
    26722680        }
    26732681      else
    26742682        {
     2683          qflags = QGLOB_CVTNULL;
     2684          if (special == 2)
     2685            qflags |= QGLOB_REGEXP;
    26752686          p = string_list (l);
    2676           r = quote_string_for_globbing (p, QGLOB_CVTNULL);
     2687          r = quote_string_for_globbing (p, qflags);
    26772688          free (p);
    26782689        }
    26792690      dispose_words (l);
     
    28032814   passed string when an error occurs.  Might want to trap other calls
    28042815   to jump_to_top_level here so we don't endlessly loop. */
    28052816WORD_LIST *
    2806 expand_prompt_string (string, quoted)
     2817expand_prompt_string (string, quoted, wflags)
    28072818     char *string;
    28082819     int quoted;
     2820     int wflags;
    28092821{
    28102822  WORD_LIST *value;
    28112823  WORD_DESC td;
     
    28132825  if (string == 0 || *string == 0)
    28142826    return ((WORD_LIST *)NULL);
    28152827
    2816   td.flags = 0;
     2828  td.flags = wflags;
    28172829  td.word = savestring (string);
    28182830
    28192831  no_longjmp_on_fatal_error = 1;
     
    29162928
    29172929/* Quote escape characters in string s, but no other characters.  This is
    29182930   used to protect CTLESC and CTLNUL in variable values from the rest of
    2919    the word expansion process after the variable is expanded. */
     2931   the word expansion process after the variable is expanded.  If IFS is
     2932   null, we quote spaces as well, just in case we split on spaces later
     2933   (in the case of unquoted $@, we will eventually attempt to split the
     2934   entire word on spaces).  Corresponding code exists in dequote_escapes.
     2935   Even if we don't end up splitting on spaces, quoting spaces is not a
     2936   problem. */
    29202937char *
    29212938quote_escapes (string)
    29222939     char *string;
     
    29242941  register char *s, *t;
    29252942  size_t slen;
    29262943  char *result, *send;
     2944  int quote_spaces;
    29272945  DECLARE_MBSTATE;
    29282946
    29292947  slen = strlen (string);
    29302948  send = string + slen;
    29312949
     2950  quote_spaces = (ifs_value && *ifs_value == 0);
    29322951  t = result = (char *)xmalloc ((slen * 2) + 1);
    29332952  s = string;
    29342953
    29352954  while (*s)
    29362955    {
    2937       if (*s == CTLESC || *s == CTLNUL)
     2956      if (*s == CTLESC || *s == CTLNUL || (quote_spaces && *s == ' '))
    29382957        *t++ = CTLESC;
    29392958      COPY_CHAR_P (t, s, send);
    29402959    }
     
    29762995  register char *s, *t;
    29772996  size_t slen;
    29782997  char *result, *send;
     2998  int quote_spaces;
    29792999  DECLARE_MBSTATE;
    29803000
    29813001  if (string == 0)
     
    29903010  if (strchr (string, CTLESC) == 0)
    29913011    return (strcpy (result, s));
    29923012
     3013  quote_spaces = (ifs_value && *ifs_value == 0);
    29933014  while (*s)
    29943015    {
    2995       if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL))
     3016      if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL || (quote_spaces && s[1] == ' ')))
    29963017        {
    29973018          s++;
    29983019          if (*s == '\0')
     
    39543975  if (patspec == RP_LONG_LEFT || patspec == RP_LONG_RIGHT)
    39553976    patstr++;
    39563977
    3957   pattern = getpattern (patstr, quoted, 1);
     3978  /* Need to pass getpattern newly-allocated memory in case of expansion --
     3979     the expansion code will free the passed string on an error. */
     3980  temp1 = savestring (patstr);
     3981  pattern = getpattern (temp1, quoted, 1);
     3982  free (temp1);
    39583983
    39593984  temp1 = (char *)NULL;         /* shut up gcc */
    39603985  switch (vtype)
     
    41234148    nfifo = 0;
    41244149}
    41254150
     4151int
     4152fifos_pending ()
     4153{
     4154  return nfifo;
     4155}
     4156
    41264157static char *
    41274158make_named_pipe ()
    41284159{
     
    41724203  nfds++;
    41734204}
    41744205
     4206int
     4207fifos_pending ()
     4208{
     4209  return 0;     /* used for cleanup; not needed with /dev/fd */
     4210}
     4211
    41754212void
    41764213unlink_fifo_list ()
    41774214{
     
    44564493      /* Add the character to ISTRING, possibly after resizing it. */
    44574494      RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size, DEFAULT_ARRAY_SIZE);
    44584495
    4459       if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || c == CTLESC || c == CTLNUL)
     4496      /* This is essentially quote_string inline */
     4497      if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) /* || c == CTLESC || c == CTLNUL */)
     4498        istring[istring_index++] = CTLESC;
     4499      /* Escape CTLESC and CTLNUL in the output to protect those characters
     4500         from the rest of the word expansions (word splitting and globbing.)
     4501         This is essentially quote_escapes inline. */
     4502      else if (c == CTLESC)
     4503        istring[istring_index++] = CTLESC;
     4504      else if (c == CTLNUL || (c == ' ' && (ifs_value && *ifs_value == 0)))
    44604505        istring[istring_index++] = CTLESC;
    44614506
    44624507      istring[istring_index++] = c;
     
    45784623#if defined (JOB_CONTROL)
    45794624  set_sigchld_handler ();
    45804625  stop_making_children ();
    4581   pipeline_pgrp = old_pipeline_pgrp;
     4626  if (pid != 0)
     4627    pipeline_pgrp = old_pipeline_pgrp;
    45824628#else
    45834629  stop_making_children ();
    45844630#endif /* JOB_CONTROL */
     
    46654711
    46664712      last_command_exit_value = rc;
    46674713      rc = run_exit_trap ();
     4714#if defined (PROCESS_SUBSTITUTION)
     4715      unlink_fifo_list ();
     4716#endif
    46684717      exit (rc);
    46694718    }
    46704719  else
     
    47634812  else
    47644813    t = (ind == 0) ? value_cell (var) : (char *)NULL;
    47654814
    4766   len = STRLEN (t);
     4815  len = MB_STRLEN (t);
    47674816  return (len);
    47684817}
    47694818#endif /* ARRAY_VARS */
     
    48604909  char *temp, *tt;
    48614910  intmax_t arg_index;
    48624911  SHELL_VAR *var;
    4863   int atype;
     4912  int atype, rflags;
    48644913
    48654914  ret = 0;
    48664915  temp = 0;
     4916  rflags = 0;
    48674917
    48684918  /* Handle multiple digit arguments, as in ${11}. */ 
    48694919  if (legal_number (name, &arg_index))
     
    48964946        temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
    48974947                  ? quote_string (temp)
    48984948                  : quote_escapes (temp);
     4949      else if (atype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
     4950        rflags |= W_HASQUOTEDNULL;
    48994951    }
    49004952#endif
    49014953  else if (var = find_variable (name))
     
    49234975    {
    49244976      ret = alloc_word_desc ();
    49254977      ret->word = temp;
     4978      ret->flags |= rflags;
    49264979    }
    49274980  return ret;
    49284981}
     
    55465599         so verify_substring_values just returns the numbers specified and we
    55475600         rely on array_subrange to understand how to deal with them). */
    55485601      tt = array_subrange (array_cell (v), e1, e2, starsub, quoted);
     5602#if 0
     5603      /* array_subrange now calls array_quote_escapes as appropriate, so the
     5604         caller no longer needs to. */
    55495605      if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0)
    55505606        {
    55515607          temp = tt ? quote_escapes (tt) : (char *)NULL;
    55525608          FREE (tt);
    55535609        }
    55545610      else
     5611#endif
    55555612        temp = tt;
    55565613      break;
    55575614#endif
     
    57075764  vtype &= ~VT_STARSUB;
    57085765
    57095766  mflags = 0;
     5767  if (patsub && *patsub == '/')
     5768    {
     5769      mflags |= MATCH_GLOBREP;
     5770      patsub++;
     5771    }
    57105772
    57115773  /* Malloc this because expand_string_if_necessary or one of the expansion
    57125774     functions in its call chain may free it on a substitution error. */
     
    57415803    }
    57425804
    57435805  /* ksh93 doesn't allow the match specifier to be a part of the expanded
    5744      pattern.  This is an extension. */
     5806     pattern.  This is an extension.  Make sure we don't anchor the pattern
     5807     at the beginning or end of the string if we're doing global replacement,
     5808     though. */
    57455809  p = pat;
    5746   if (pat && pat[0] == '/')
    5747     {
    5748       mflags |= MATCH_GLOBREP|MATCH_ANY;
    5749       p++;
    5750     }
     5810  if (mflags & MATCH_GLOBREP)
     5811    mflags |= MATCH_ANY;
    57515812  else if (pat && pat[0] == '#')
    57525813    {
    57535814      mflags |= MATCH_BEG;
     
    57985859#if defined (ARRAY_VARS)
    57995860    case VT_ARRAYVAR:
    58005861      temp = array_patsub (array_cell (v), p, rep, mflags);
     5862#if 0
     5863      /* Don't need to do this anymore; array_patsub calls array_quote_escapes
     5864         as appropriate before adding the space separators. */
    58015865      if (temp && (mflags & MATCH_QUOTED) == 0)
    58025866        {
    58035867          tt = quote_escapes (temp);
    58045868          free (temp);
    58055869          temp = tt;
    58065870        }
     5871#endif
    58075872      break;
    58085873#endif
    58095874    }
     
    76077672  expand_no_split_dollar_star = 0;      /* XXX */
    76087673  expanding_redir = 0;
    76097674
     7675  if (parse_and_execute_level == 0)
     7676    top_level_cleanup ();                       /* from sig.c */
     7677
     7678
    76107679  jump_to_top_level (v);
    76117680}
    76127681
     
    78247893          else if (fail_glob_expansion != 0)
    78257894            {
    78267895              report_error (_("no match: %s"), tlist->word->word);
    7827               jump_to_top_level (DISCARD);
     7896              exp_jump_to_top_level (DISCARD);
    78287897            }
    78297898          else if (allow_null_glob_expansion == 0)
    78307899            {
  • subst.h

    diff -Naur bash-3.2.orig/subst.h bash-3.2/subst.h
    old new  
    135135extern WORD_LIST *expand_string_assignment __P((char *, int));
    136136
    137137/* Expand a prompt string. */
    138 extern WORD_LIST *expand_prompt_string __P((char *, int));
     138extern WORD_LIST *expand_prompt_string __P((char *, int, int));
    139139
    140140/* Expand STRING just as if you were expanding a word.  This also returns
    141141   a list of words.  Note that filename globbing is *NOT* done for word
     
    222222extern char *command_substitute __P((char *, int));
    223223extern char *pat_subst __P((char *, char *, char *, int));
    224224
     225extern int fifos_pending __P((void));
    225226extern void unlink_fifo_list __P((void));
    226227
    227228extern WORD_LIST *list_string_with_quotes __P((char *));
  • tests/new-exp.right

    diff -Naur bash-3.2.orig/tests/new-exp.right bash-3.2/tests/new-exp.right
    old new  
    430430Case06---1---A B C::---
    431431Case07---3---A:B:C---
    432432Case08---3---A:B:C---
    433 ./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
     433./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
    434434argv[1] = <a>
    435435argv[2] = <b>
    436436argv[3] = <c>
  • tests/shopt.right

    diff -Naur bash-3.2.orig/tests/shopt.right bash-3.2/tests/shopt.right
    old new  
    66shopt -u checkhash
    77shopt -u checkwinsize
    88shopt -s cmdhist
     9shopt -u compat31
    910shopt -u dotglob
    1011shopt -u execfail
    1112shopt -s expand_aliases
     
    5354shopt -u cdable_vars
    5455shopt -u checkhash
    5556shopt -u checkwinsize
     57shopt -u compat31
    5658shopt -u dotglob
    5759shopt -u execfail
    5860shopt -u extdebug
     
    7779cdable_vars     off
    7880checkhash       off
    7981checkwinsize    off
     82compat31        off
    8083dotglob         off
    8184execfail        off
    8285extdebug        off
  • variables.c

    diff -Naur bash-3.2.orig/variables.c bash-3.2/variables.c
    old new  
    18211821          oval = value_cell (var);
    18221822          lval = evalexp (oval, &expok);        /* ksh93 seems to do this */
    18231823          if (expok == 0)
    1824             jump_to_top_level (DISCARD);
     1824            {
     1825              top_level_cleanup ();
     1826              jump_to_top_level (DISCARD);
     1827            }
    18251828        }
    18261829      rval = evalexp (value, &expok);
    18271830      if (expok == 0)
    1828         jump_to_top_level (DISCARD);
     1831        {
     1832          top_level_cleanup ();
     1833          jump_to_top_level (DISCARD);
     1834        }
    18291835      if (flags & ASS_APPEND)
    18301836        rval += lval;
    18311837      retval = itos (rval);
     
    34523458      if (shell_variables == global_variables)
    34533459        var->attributes &= ~(att_tempvar|att_propagate);
    34543460      else
    3455         shell_variables->flags |= VC_HASTMPVAR;
     3461        shell_variables->flags |= VC_HASTMPVAR;
    34563462      v->attributes |= var->attributes;
    34573463    }
     3464  else
     3465    stupidly_hack_special_variables (var->name);        /* XXX */
    34583466
    34593467  dispose_variable (var);
    34603468}
     
    35413549        var->attributes &= ~att_propagate;
    35423550      v->attributes |= var->attributes;
    35433551    }
     3552  else
     3553    stupidly_hack_special_variables (var->name);        /* XXX */
    35443554
    35453555  dispose_variable (var);
    35463556}
  • version.c

    diff -Naur bash-3.2.orig/version.c bash-3.2/version.c
    old new  
    4343#endif
    4444const char *sccs_version = SCCSVERSION;
    4545
     46/* If == 31, shell compatible with bash-3.1, == 32 with bash-3.2, and so on */
     47int shell_compatibility_level = 32;
     48
    4649/* Functions for getting, setting, and displaying the shell version. */
    4750
    4851/* Forward declarations so we don't have to include externs.h */
     
    7982{
    8083  printf ("GNU bash, version %s (%s)\n", shell_version_string (), MACHTYPE);
    8184  if (extended)
    82     printf (_("Copyright (C) 2005 Free Software Foundation, Inc.\n"));
     85    printf (_("Copyright (C) 2007 Free Software Foundation, Inc.\n"));
    8386}
Note: See TracBrowser for help on using the repository browser.