aboutsummaryrefslogtreecommitdiffstats
path: root/package/bash/bash32-022
blob: aaf3337c9ed3e4e5bd403c234ec1f756276a4b21 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
			     BASH PATCH REPORT
			     =================

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

Bug-Reported-by:	Chet Ramey <chet.ramey@cwru.edu>
Bug-Reference-ID:
Bug-Reference-URL:

Bug-Description:

POSIX specifies that the `read' builtin invoked from an interative shell
must prompt with $PS2 when a line is continued using a backslash while
reading from a terminal.

Patch:

*** ../bash-3.2-patched/builtins/read.def	Tue Sep 19 08:45:48 2006
--- bash-3.2/builtins/read.def	Thu May 24 16:03:30 2007
***************
*** 128,133 ****
  {
    register char *varname;
!   int size, i, nr, pass_next, saw_escape, eof, opt, retval, code;
!   int input_is_tty, input_is_pipe, unbuffered_read;
    int raw, edit, nchars, silent, have_timeout, fd;
    unsigned int tmout;
--- 131,136 ----
  {
    register char *varname;
!   int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
!   int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
    int raw, edit, nchars, silent, have_timeout, fd;
    unsigned int tmout;
***************
*** 135,139 ****
    char c;
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
!   char *e, *t, *t1;
    struct stat tsb;
    SHELL_VAR *var;
--- 138,142 ----
    char c;
    char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
!   char *e, *t, *t1, *ps2;
    struct stat tsb;
    SHELL_VAR *var;
***************
*** 149,152 ****
--- 152,156 ----
    USE_VAR(i);
    USE_VAR(pass_next);
+   USE_VAR(print_ps2);
    USE_VAR(saw_escape);
    USE_VAR(input_is_pipe);
***************
*** 164,167 ****
--- 168,172 ----
  #endif
    USE_VAR(list);
+   USE_VAR(ps2);
  
    i = 0;		/* Index into the string that we are reading. */
***************
*** 387,391 ****
  #endif
  
!   for (eof = retval = 0;;)
      {
  #if defined (READLINE)
--- 394,399 ----
  #endif
  
!   ps2 = 0;
!   for (print_ps2 = eof = retval = 0;;)
      {
  #if defined (READLINE)
***************
*** 413,416 ****
--- 421,433 ----
  #endif
  
+       if (print_ps2)
+ 	{
+ 	  if (ps2 == 0)
+ 	    ps2 = get_string_value ("PS2");
+ 	  fprintf (stderr, "%s", ps2 ? ps2 : "");
+ 	  fflush (stderr);
+ 	  print_ps2 = 0;
+ 	}
+ 
        if (unbuffered_read)
  	retval = zread (fd, &c, 1);
***************
*** 441,445 ****
  	  pass_next = 0;
  	  if (c == '\n')
! 	    i--;		/* back up over the CTLESC */
  	  else
  	    goto add_char;
--- 458,466 ----
  	  pass_next = 0;
  	  if (c == '\n')
! 	    {
! 	      i--;		/* back up over the CTLESC */
! 	      if (interactive && input_is_tty && raw == 0)
! 		print_ps2 = 1;
! 	    }
  	  else
  	    goto add_char;
*** ../bash-3.2/patchlevel.h	Thu Apr 13 08:31:04 2006
--- bash-3.2/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 21
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 22
  
  #endif /* _PATCHLEVEL_H_ */