Bash-4.2 Official Patch 38

2012-11-02 Thread Chet Ramey
 BASH PATCH REPORT
 =

Bash-Release:   4.2
Patch-ID:   bash42-038

Bug-Reported-by:arman...@gmail.com
Bug-Reference-ID:   <20120822112810.8d14920...@windmill.latviatours.lv>
Bug-Reference-URL:  
http://lists.gnu.org/archive/html/bug-bash/2012-08/msg00049.html

Bug-Description:

If a backslash-newline (which is removed) with no other input is given as
input to `read', the shell tries to dereference a null pointer and seg faults.

Patch (apply with `patch -p0'):

*** ../bash-4.2-patched/builtins/read.def   2012-03-11 17:52:44.0 
-0400
--- builtins/read.def   2012-08-22 11:53:09.0 -0400
***
*** 792,796 
  #endif
  
!   if (saw_escape)
  {
t = dequote_string (input_string);
--- 847,851 
  #endif
  
!   if (saw_escape && input_string && *input_string)
  {
t = dequote_string (input_string);
*** ../bash-4.2-patched/patchlevel.hSat Jun 12 20:14:48 2010
--- patchlevel.hThu Feb 24 21:41:34 2011
***
*** 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 37
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 38
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Bash-4.2 Official Patch 39

2012-11-02 Thread Chet Ramey
 BASH PATCH REPORT
 =

Bash-Release:   4.2
Patch-ID:   bash42-039

Bug-Reported-by:Dan Douglas 
Bug-Reference-ID:   <1498458.MpVlmOXDB7@smorgbox>
Bug-Reference-URL:  
http://lists.gnu.org/archive/html/bug-bash/2012-09/msg8.html

Bug-Description:

Under certain circumstances, bash attempts to expand variables in arithmetic
expressions even when evaluation is being suppressed.

Patch (apply with `patch -p0'):

*** ../bash-4.2-patched/expr.c  2011-11-21 18:03:35.0 -0500
--- expr.c  2012-09-09 16:31:18.0 -0400
***
*** 1010,1013 
--- 1073,1082 
  #endif
  
+ /*itrace("expr_streval: %s: noeval = %d", tok, noeval);*/
+   /* If we are suppressing evaluation, just short-circuit here instead of
+  going through the rest of the evaluator. */
+   if (noeval)
+ return (0);
+ 
/* [ */
  #if defined (ARRAY_VARS)
***
*** 1183,1186 
--- 1256,1263 
  
*cp = '\0';
+   /* XXX - watch out for pointer aliasing issues here */
+   if (curlval.tokstr && curlval.tokstr == tokstr)
+   init_lvalue (&curlval);
+ 
FREE (tokstr);
tokstr = savestring (tp);
*** ../bash-4.2-patched/patchlevel.hSat Jun 12 20:14:48 2010
--- patchlevel.hThu Feb 24 21:41:34 2011
***
*** 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 38
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 39
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Trap variable scope

2012-11-02 Thread Nikolai Kondrashov

Hi everyone,

I've encountered a very strange behavior regarding variable scope and traps,
which looks very much like a bug.

This command:

echo '
set -e;
tt() { declare -r v=; };t() { tt; };
ff() { declare -r v=; false; }; f() { ff; };
trap t EXIT;
f
' | bash

produces this error message:
bash: line 3: declare: v: readonly variable

While this:

bash -c '
set -e;
tt() { declare -r v=; };t() { tt; };
ff() { declare -r v=; false; }; f() { ff; };
trap t EXIT;
f
'

doesn't. As don't these:

echo '
set -e;
tt() { declare -r v=; };t() { tt; };
ff() { declare -r v=; false; };
trap t EXIT;
ff
' | bash

echo '
set -e;
tt() { declare -r v=; };
ff() { declare -r v=; false; }; f() { ff; };
trap tt EXIT;
f
' | bash

Could this indeed be a bug? If yes, can it be fixed?

Thank you.

Sincerely,
Nick