Merge lp:~percona-toolkit-dev/percona-toolkit/pt-show-grant-ask-pass-print-Enter-password-in-stdout-1290911 into lp:percona-toolkit/2.2

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 599
Merged at revision: 602
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-show-grant-ask-pass-print-Enter-password-in-stdout-1290911
Merge into: lp:percona-toolkit/2.2
Diff against target: 394 lines (+56/-27)
28 files modified
bin/pt-agent (+1/-1)
bin/pt-align (+1/-1)
bin/pt-archiver (+1/-1)
bin/pt-config-diff (+1/-1)
bin/pt-deadlock-logger (+1/-1)
bin/pt-diskstats (+1/-1)
bin/pt-duplicate-key-checker (+1/-1)
bin/pt-fifo-split (+1/-1)
bin/pt-find (+1/-1)
bin/pt-fingerprint (+1/-1)
bin/pt-fk-error-logger (+1/-1)
bin/pt-heartbeat (+1/-1)
bin/pt-index-usage (+1/-1)
bin/pt-kill (+1/-1)
bin/pt-online-schema-change (+1/-1)
bin/pt-query-digest (+1/-1)
bin/pt-show-grants (+1/-1)
bin/pt-slave-delay (+1/-1)
bin/pt-slave-find (+1/-1)
bin/pt-slave-restart (+1/-1)
bin/pt-table-checksum (+1/-1)
bin/pt-table-sync (+1/-1)
bin/pt-table-usage (+1/-1)
bin/pt-upgrade (+1/-1)
bin/pt-variable-advisor (+1/-1)
bin/pt-visual-explain (+1/-1)
lib/OptionParser.pm (+1/-1)
t/lib/OptionParser.t (+29/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-show-grant-ask-pass-print-Enter-password-in-stdout-1290911
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+220866@code.launchpad.net

Description of the change

Changed OptionParser prompt_noecho function to output prompt to STDERR instead of STDOUT
This makes it easier to direct output to a file for tools that ask for a password.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-agent'
2--- bin/pt-agent 2014-02-20 08:10:16 +0000
3+++ bin/pt-agent 2014-05-24 21:44:55 +0000
4@@ -3381,7 +3381,7 @@
5 shift @_ if ref $_[0] eq __PACKAGE__;
6 my ( $prompt ) = @_;
7 local $OUTPUT_AUTOFLUSH = 1;
8- print $prompt
9+ print STDERR $prompt
10 or die "Cannot print: $OS_ERROR";
11 my $response;
12 eval {
13
14=== modified file 'bin/pt-align'
15--- bin/pt-align 2014-02-20 08:10:16 +0000
16+++ bin/pt-align 2014-05-24 21:44:55 +0000
17@@ -866,7 +866,7 @@
18 shift @_ if ref $_[0] eq __PACKAGE__;
19 my ( $prompt ) = @_;
20 local $OUTPUT_AUTOFLUSH = 1;
21- print $prompt
22+ print STDERR $prompt
23 or die "Cannot print: $OS_ERROR";
24 my $response;
25 eval {
26
27=== modified file 'bin/pt-archiver'
28--- bin/pt-archiver 2014-02-20 08:10:16 +0000
29+++ bin/pt-archiver 2014-05-24 21:44:55 +0000
30@@ -1593,7 +1593,7 @@
31 shift @_ if ref $_[0] eq __PACKAGE__;
32 my ( $prompt ) = @_;
33 local $OUTPUT_AUTOFLUSH = 1;
34- print $prompt
35+ print STDERR $prompt
36 or die "Cannot print: $OS_ERROR";
37 my $response;
38 eval {
39
40=== modified file 'bin/pt-config-diff'
41--- bin/pt-config-diff 2014-02-20 08:10:16 +0000
42+++ bin/pt-config-diff 2014-05-24 21:44:55 +0000
43@@ -1593,7 +1593,7 @@
44 shift @_ if ref $_[0] eq __PACKAGE__;
45 my ( $prompt ) = @_;
46 local $OUTPUT_AUTOFLUSH = 1;
47- print $prompt
48+ print STDERR $prompt
49 or die "Cannot print: $OS_ERROR";
50 my $response;
51 eval {
52
53=== modified file 'bin/pt-deadlock-logger'
54--- bin/pt-deadlock-logger 2014-02-20 08:10:16 +0000
55+++ bin/pt-deadlock-logger 2014-05-24 21:44:55 +0000
56@@ -943,7 +943,7 @@
57 shift @_ if ref $_[0] eq __PACKAGE__;
58 my ( $prompt ) = @_;
59 local $OUTPUT_AUTOFLUSH = 1;
60- print $prompt
61+ print STDERR $prompt
62 or die "Cannot print: $OS_ERROR";
63 my $response;
64 eval {
65
66=== modified file 'bin/pt-diskstats'
67--- bin/pt-diskstats 2014-02-20 08:10:16 +0000
68+++ bin/pt-diskstats 2014-05-24 21:44:55 +0000
69@@ -939,7 +939,7 @@
70 shift @_ if ref $_[0] eq __PACKAGE__;
71 my ( $prompt ) = @_;
72 local $OUTPUT_AUTOFLUSH = 1;
73- print $prompt
74+ print STDERR $prompt
75 or die "Cannot print: $OS_ERROR";
76 my $response;
77 eval {
78
79=== modified file 'bin/pt-duplicate-key-checker'
80--- bin/pt-duplicate-key-checker 2014-02-20 08:10:16 +0000
81+++ bin/pt-duplicate-key-checker 2014-05-24 21:44:55 +0000
82@@ -1927,7 +1927,7 @@
83 shift @_ if ref $_[0] eq __PACKAGE__;
84 my ( $prompt ) = @_;
85 local $OUTPUT_AUTOFLUSH = 1;
86- print $prompt
87+ print STDERR $prompt
88 or die "Cannot print: $OS_ERROR";
89 my $response;
90 eval {
91
92=== modified file 'bin/pt-fifo-split'
93--- bin/pt-fifo-split 2014-02-20 08:10:16 +0000
94+++ bin/pt-fifo-split 2014-05-24 21:44:55 +0000
95@@ -867,7 +867,7 @@
96 shift @_ if ref $_[0] eq __PACKAGE__;
97 my ( $prompt ) = @_;
98 local $OUTPUT_AUTOFLUSH = 1;
99- print $prompt
100+ print STDERR $prompt
101 or die "Cannot print: $OS_ERROR";
102 my $response;
103 eval {
104
105=== modified file 'bin/pt-find'
106--- bin/pt-find 2014-02-20 08:10:16 +0000
107+++ bin/pt-find 2014-05-24 21:44:55 +0000
108@@ -1359,7 +1359,7 @@
109 shift @_ if ref $_[0] eq __PACKAGE__;
110 my ( $prompt ) = @_;
111 local $OUTPUT_AUTOFLUSH = 1;
112- print $prompt
113+ print STDERR $prompt
114 or die "Cannot print: $OS_ERROR";
115 my $response;
116 eval {
117
118=== modified file 'bin/pt-fingerprint'
119--- bin/pt-fingerprint 2014-02-20 08:10:16 +0000
120+++ bin/pt-fingerprint 2014-05-24 21:44:55 +0000
121@@ -868,7 +868,7 @@
122 shift @_ if ref $_[0] eq __PACKAGE__;
123 my ( $prompt ) = @_;
124 local $OUTPUT_AUTOFLUSH = 1;
125- print $prompt
126+ print STDERR $prompt
127 or die "Cannot print: $OS_ERROR";
128 my $response;
129 eval {
130
131=== modified file 'bin/pt-fk-error-logger'
132--- bin/pt-fk-error-logger 2014-02-20 08:10:16 +0000
133+++ bin/pt-fk-error-logger 2014-05-24 21:44:55 +0000
134@@ -938,7 +938,7 @@
135 shift @_ if ref $_[0] eq __PACKAGE__;
136 my ( $prompt ) = @_;
137 local $OUTPUT_AUTOFLUSH = 1;
138- print $prompt
139+ print STDERR $prompt
140 or die "Cannot print: $OS_ERROR";
141 my $response;
142 eval {
143
144=== modified file 'bin/pt-heartbeat'
145--- bin/pt-heartbeat 2014-02-20 08:10:16 +0000
146+++ bin/pt-heartbeat 2014-05-24 21:44:55 +0000
147@@ -1675,7 +1675,7 @@
148 shift @_ if ref $_[0] eq __PACKAGE__;
149 my ( $prompt ) = @_;
150 local $OUTPUT_AUTOFLUSH = 1;
151- print $prompt
152+ print STDERR $prompt
153 or die "Cannot print: $OS_ERROR";
154 my $response;
155 eval {
156
157=== modified file 'bin/pt-index-usage'
158--- bin/pt-index-usage 2014-02-20 08:10:16 +0000
159+++ bin/pt-index-usage 2014-05-24 21:44:55 +0000
160@@ -1520,7 +1520,7 @@
161 shift @_ if ref $_[0] eq __PACKAGE__;
162 my ( $prompt ) = @_;
163 local $OUTPUT_AUTOFLUSH = 1;
164- print $prompt
165+ print STDERR $prompt
166 or die "Cannot print: $OS_ERROR";
167 my $response;
168 eval {
169
170=== modified file 'bin/pt-kill'
171--- bin/pt-kill 2014-02-20 08:10:16 +0000
172+++ bin/pt-kill 2014-05-24 21:44:55 +0000
173@@ -948,7 +948,7 @@
174 shift @_ if ref $_[0] eq __PACKAGE__;
175 my ( $prompt ) = @_;
176 local $OUTPUT_AUTOFLUSH = 1;
177- print $prompt
178+ print STDERR $prompt
179 or die "Cannot print: $OS_ERROR";
180 my $response;
181 eval {
182
183=== modified file 'bin/pt-online-schema-change'
184--- bin/pt-online-schema-change 2014-02-20 08:10:16 +0000
185+++ bin/pt-online-schema-change 2014-05-24 21:44:55 +0000
186@@ -955,7 +955,7 @@
187 shift @_ if ref $_[0] eq __PACKAGE__;
188 my ( $prompt ) = @_;
189 local $OUTPUT_AUTOFLUSH = 1;
190- print $prompt
191+ print STDERR $prompt
192 or die "Cannot print: $OS_ERROR";
193 my $response;
194 eval {
195
196=== modified file 'bin/pt-query-digest'
197--- bin/pt-query-digest 2014-02-20 08:10:16 +0000
198+++ bin/pt-query-digest 2014-05-24 21:44:55 +0000
199@@ -2188,7 +2188,7 @@
200 shift @_ if ref $_[0] eq __PACKAGE__;
201 my ( $prompt ) = @_;
202 local $OUTPUT_AUTOFLUSH = 1;
203- print $prompt
204+ print STDERR $prompt
205 or die "Cannot print: $OS_ERROR";
206 my $response;
207 eval {
208
209=== modified file 'bin/pt-show-grants'
210--- bin/pt-show-grants 2014-02-20 08:10:16 +0000
211+++ bin/pt-show-grants 2014-05-24 21:44:55 +0000
212@@ -868,7 +868,7 @@
213 shift @_ if ref $_[0] eq __PACKAGE__;
214 my ( $prompt ) = @_;
215 local $OUTPUT_AUTOFLUSH = 1;
216- print $prompt
217+ print STDERR $prompt
218 or die "Cannot print: $OS_ERROR";
219 my $response;
220 eval {
221
222=== modified file 'bin/pt-slave-delay'
223--- bin/pt-slave-delay 2014-02-20 08:10:16 +0000
224+++ bin/pt-slave-delay 2014-05-24 21:44:55 +0000
225@@ -941,7 +941,7 @@
226 shift @_ if ref $_[0] eq __PACKAGE__;
227 my ( $prompt ) = @_;
228 local $OUTPUT_AUTOFLUSH = 1;
229- print $prompt
230+ print STDERR $prompt
231 or die "Cannot print: $OS_ERROR";
232 my $response;
233 eval {
234
235=== modified file 'bin/pt-slave-find'
236--- bin/pt-slave-find 2014-02-20 08:10:16 +0000
237+++ bin/pt-slave-find 2014-05-24 21:44:55 +0000
238@@ -876,7 +876,7 @@
239 shift @_ if ref $_[0] eq __PACKAGE__;
240 my ( $prompt ) = @_;
241 local $OUTPUT_AUTOFLUSH = 1;
242- print $prompt
243+ print STDERR $prompt
244 or die "Cannot print: $OS_ERROR";
245 my $response;
246 eval {
247
248=== modified file 'bin/pt-slave-restart'
249--- bin/pt-slave-restart 2014-02-20 08:10:16 +0000
250+++ bin/pt-slave-restart 2014-05-24 21:44:55 +0000
251@@ -1093,7 +1093,7 @@
252 shift @_ if ref $_[0] eq __PACKAGE__;
253 my ( $prompt ) = @_;
254 local $OUTPUT_AUTOFLUSH = 1;
255- print $prompt
256+ print STDERR $prompt
257 or die "Cannot print: $OS_ERROR";
258 my $response;
259 eval {
260
261=== modified file 'bin/pt-table-checksum'
262--- bin/pt-table-checksum 2014-02-20 08:10:16 +0000
263+++ bin/pt-table-checksum 2014-05-24 21:44:55 +0000
264@@ -2605,7 +2605,7 @@
265 shift @_ if ref $_[0] eq __PACKAGE__;
266 my ( $prompt ) = @_;
267 local $OUTPUT_AUTOFLUSH = 1;
268- print $prompt
269+ print STDERR $prompt
270 or die "Cannot print: $OS_ERROR";
271 my $response;
272 eval {
273
274=== modified file 'bin/pt-table-sync'
275--- bin/pt-table-sync 2014-02-20 08:10:16 +0000
276+++ bin/pt-table-sync 2014-05-24 21:44:55 +0000
277@@ -956,7 +956,7 @@
278 shift @_ if ref $_[0] eq __PACKAGE__;
279 my ( $prompt ) = @_;
280 local $OUTPUT_AUTOFLUSH = 1;
281- print $prompt
282+ print STDERR $prompt
283 or die "Cannot print: $OS_ERROR";
284 my $response;
285 eval {
286
287=== modified file 'bin/pt-table-usage'
288--- bin/pt-table-usage 2014-02-20 08:10:16 +0000
289+++ bin/pt-table-usage 2014-05-24 21:44:55 +0000
290@@ -1305,7 +1305,7 @@
291 shift @_ if ref $_[0] eq __PACKAGE__;
292 my ( $prompt ) = @_;
293 local $OUTPUT_AUTOFLUSH = 1;
294- print $prompt
295+ print STDERR $prompt
296 or die "Cannot print: $OS_ERROR";
297 my $response;
298 eval {
299
300=== modified file 'bin/pt-upgrade'
301--- bin/pt-upgrade 2014-02-20 08:10:16 +0000
302+++ bin/pt-upgrade 2014-05-24 21:44:55 +0000
303@@ -2185,7 +2185,7 @@
304 shift @_ if ref $_[0] eq __PACKAGE__;
305 my ( $prompt ) = @_;
306 local $OUTPUT_AUTOFLUSH = 1;
307- print $prompt
308+ print STDERR $prompt
309 or die "Cannot print: $OS_ERROR";
310 my $response;
311 eval {
312
313=== modified file 'bin/pt-variable-advisor'
314--- bin/pt-variable-advisor 2014-02-20 08:10:16 +0000
315+++ bin/pt-variable-advisor 2014-05-24 21:44:55 +0000
316@@ -945,7 +945,7 @@
317 shift @_ if ref $_[0] eq __PACKAGE__;
318 my ( $prompt ) = @_;
319 local $OUTPUT_AUTOFLUSH = 1;
320- print $prompt
321+ print STDERR $prompt
322 or die "Cannot print: $OS_ERROR";
323 my $response;
324 eval {
325
326=== modified file 'bin/pt-visual-explain'
327--- bin/pt-visual-explain 2014-02-20 08:10:16 +0000
328+++ bin/pt-visual-explain 2014-05-24 21:44:55 +0000
329@@ -1542,7 +1542,7 @@
330 shift @_ if ref $_[0] eq __PACKAGE__;
331 my ( $prompt ) = @_;
332 local $OUTPUT_AUTOFLUSH = 1;
333- print $prompt
334+ print STDERR $prompt
335 or die "Cannot print: $OS_ERROR";
336 my $response;
337 eval {
338
339=== modified file 'lib/OptionParser.pm'
340--- lib/OptionParser.pm 2013-11-08 01:47:10 +0000
341+++ lib/OptionParser.pm 2014-05-24 21:44:55 +0000
342@@ -1090,7 +1090,7 @@
343 shift @_ if ref $_[0] eq __PACKAGE__;
344 my ( $prompt ) = @_;
345 local $OUTPUT_AUTOFLUSH = 1;
346- print $prompt
347+ print STDERR $prompt
348 or die "Cannot print: $OS_ERROR";
349 my $response;
350 eval {
351
352=== modified file 't/lib/OptionParser.t'
353--- t/lib/OptionParser.t 2013-08-08 02:02:11 +0000
354+++ t/lib/OptionParser.t 2014-05-24 21:44:55 +0000
355@@ -2117,6 +2117,32 @@
356 "--optimize got its value (bug 1199589)"
357 );
358
359+
360+# #############################################################################
361+# Issue 1290911 : prompt_noecho should send prompt to STDERR so user can
362+# direct STDOUT to a file and still see the prompt
363+# #############################################################################
364+
365+$o = new OptionParser();
366+
367+$output = output(
368+ sub {
369+ my $input = "thepassword";
370+ local *STDIN;
371+ open STDIN, '<', \$input;
372+ $o->prompt_noecho('Test Prompt:'); },
373+
374+ stderr=>1,
375+ );
376+
377+is (
378+ $output,
379+ "Test Prompt:\n",
380+ 'prompt_no_echo outputs prompt to STDERR'
381+);
382+
383+
384+
385 # #############################################################################
386 # Done.
387 # #############################################################################
388@@ -2133,3 +2159,6 @@
389
390 done_testing;
391 exit;
392+
393+
394+

Subscribers

People subscribed via source and target branches