summaryrefslogtreecommitdiff
path: root/data/bash/bash32-004
blob: cd2accfa3f3bfab0ee6431496953dddef7c705cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
			     BASH PATCH REPORT
			     =================

Bash-Release: 3.2
Patch-ID: bash32-004

Bug-Reported-by:	Stuart Shelton <srcshelton@gmail.com>
Bug-Reference-ID:	<619141e40610261203y6cda5aa6i23cb24c7aeba996e@mail.gmail.com>
Bug-Reference-URL:	

Bug-Description:

A bug in the parameter pattern substitution implementation treated a pattern
whose first character was `/' (after expansion) as specifying global
replacement.

Patch:

*** ../bash-3.2/subst.c	Tue Sep 19 08:35:09 2006
--- subst.c	Thu Oct 26 09:17:50 2006
***************
*** 5707,5712 ****
--- 5707,5717 ----
    vtype &= ~VT_STARSUB;
  
    mflags = 0;
+   if (patsub && *patsub == '/')
+     {
+       mflags |= MATCH_GLOBREP;
+       patsub++;
+     }
  
    /* Malloc this because expand_string_if_necessary or one of the expansion
       functions in its call chain may free it on a substitution error. */
***************
*** 5741,5753 ****
      }
  
    /* ksh93 doesn't allow the match specifier to be a part of the expanded
!      pattern.  This is an extension. */
    p = pat;
!   if (pat && pat[0] == '/')
!     {
!       mflags |= MATCH_GLOBREP|MATCH_ANY;
!       p++;
!     }
    else if (pat && pat[0] == '#')
      {
        mflags |= MATCH_BEG;
--- 5746,5757 ----
      }
  
    /* ksh93 doesn't allow the match specifier to be a part of the expanded
!      pattern.  This is an extension.  Make sure we don't anchor the pattern
!      at the beginning or end of the string if we're doing global replacement,
!      though. */
    p = pat;
!   if (mflags & MATCH_GLOBREP)
!     mflags |= MATCH_ANY;
    else if (pat && pat[0] == '#')
      {
        mflags |= MATCH_BEG;
*** ../bash-3.2/tests/new-exp.right	Thu Aug 10 12:00:00 2006
--- tests/new-exp.right	Sun Oct 29 16:03:36 2006
***************
*** 430,436 ****
  Case06---1---A B C::---
  Case07---3---A:B:C---
  Case08---3---A:B:C---
! ./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
  argv[1] = <a>
  argv[2] = <b>
  argv[3] = <c>
--- 430,436 ----
  Case06---1---A B C::---
  Case07---3---A:B:C---
  Case08---3---A:B:C---
! ./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
  argv[1] = <a>
  argv[2] = <b>
  argv[3] = <c>
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
--- patchlevel.h	Mon Oct 16 14:22:54 2006
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 3
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 4
  
  #endif /* _PATCHLEVEL_H_ */