This queue is for tickets about the IO-Prompt CPAN distribution.

Report information
The Basics
Id:
15290
Status:
new
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
japh [...] tirwhan.org
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
0.99.2
Fixed in:
(no value)



MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Subject: -wipe flag has no effect (patch included)
Content-Type: multipart/mixed; boundary="----------=_1130257845-25354-0"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 660
Hi Damian, specifying the -wipe flag does not have any effect, the -w flag without an argument results in an error message "Missing argument for -w option at -e line 1". I've attached three patches against 0.99.2 (to be applied on top of each other, I wasn't sure whether you'd consider all of them appropriate), patch 1 enables the long form -wipe, patch 2 enables -w as wipe if no further arguments are given (if an argument is given, it is parsed as -while, as per the docs). Patch 3 adds some more DWIMery and also enables correct cuddling of argument-requiring flags (e.g. 'prompt -ei,"*"' now does the correct thing instead of ignoring the -i option).
Content-Type: text/x-diff; name="patches"
Content-Disposition: inline; filename="patches"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 3530
Patch 1: Index: lib/IO/Prompt.pm =================================================================== --- lib/IO/Prompt.pm (Revision 1) +++ lib/IO/Prompt.pm (Revision 2) @@ -63,6 +63,7 @@ $flags_noarg{$_} = $_ for values %flags_noarg; my $flag_with_arg = join '|', reverse sort keys %flags_arg; +$flag_with_arg =~ s{\|w\|}{\|w(?!ipe)\|}; my $flag_no_arg = join '|', reverse sort keys %flags_noarg; my %yespat = ( @@ -187,7 +188,7 @@ $flags{-set_underscore} ||= want('BOOL'); $clearfirst = 1 if !defined($clearfirst) && $flags{-clearfirst}; - _clear($flags{ -clear } || $clearfirst); + _clear($flags{ -wipe } || $clearfirst); my $input; if (-t $IN and defined $input{$caller}) { $input = _fake_from_DATA($caller, $IN, $OUT, \%flags, @prompt); Patch 2: Index: lib/IO/Prompt.pm =================================================================== --- lib/IO/Prompt.pm (Revision 2) +++ lib/IO/Prompt.pm (Revision 3) @@ -117,10 +117,18 @@ $flags->{-yesno}{noprompt} = substr $1, 0, 1; } elsif (m/^-($flag_with_arg)/) { - croak "Missing argument for $_ option" if @data < $i+2; - s/^-($flag_with_arg)/-/; - $flags->{ -$flags_arg{$1} } = $data[ $i + 1 ]; - undef $data[ $i++ ]; + if (@data < $i+2) { + if (s/^-(w)/-/) { + $flags->{ -$flags_noarg{$1} } = 1; + } + else { + croak "Missing argument for $_ option"; + } + } else { + s/^-($flag_with_arg)/-/; + $flags->{ -$flags_arg{$1} } = $data[ $i + 1 ]; + undef $data[ $i++ ]; + } } elsif (s/^-($flag_no_arg)/-/) { $flags->{ -$flags_noarg{$1} } = 1; Patch 3: Index: lib/IO/Prompt.pm =================================================================== --- lib/IO/Prompt.pm (Revision 3) +++ lib/IO/Prompt.pm (Revision 4) @@ -116,25 +116,20 @@ $flags->{-yesno}{no} = $nopat{ substr $1, 0, 1 }; $flags->{-yesno}{noprompt} = substr $1, 0, 1; } - elsif (m/^-($flag_with_arg)/) { - if (@data < $i+2) { - if (s/^-(w)/-/) { - $flags->{ -$flags_noarg{$1} } = 1; - } - else { - croak "Missing argument for $_ option"; - } - } else { - s/^-($flag_with_arg)/-/; - $flags->{ -$flags_arg{$1} } = $data[ $i + 1 ]; - undef $data[ $i++ ]; - } + elsif (!m/^-($flag_with_arg)/ && !m/^-($flag_no_arg)/) { + croak "Unknown flag ($_) in prompt" } - elsif (s/^-($flag_no_arg)/-/) { + elsif ((@data < $i+2) && !m/^-($flag_no_arg)/) { + croak "Missing argument for $_ option"; + } + elsif ((@data >= $i+2) && s/^-($flag_with_arg)/-/) { + $flags->{ -$flags_arg{$1} } = $data[ $i + 1 ]; + splice(@data,$i+1,1); + } + else { + s/^-($flag_no_arg)/-/; $flags->{ -$flags_noarg{$1} } = 1; } - else { croak "Unknown flag ($_) in prompt" } - redo if defined $_ && /^-./; } else { next }
Return-Path: <thoughtstream@gmail.com>
X-Original-To: bug-IO-Prompt@rt.cpan.org
Delivered-To: cpan-bug+io-prompt@diesel.bestpractical.com
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id B3B174D8171 for <bug-IO-Prompt@rt.cpan.org>; Mon, 7 Nov 2005 18:34:15 -0500 (EST)
Received: (qmail 738 invoked by alias); 7 Nov 2005 23:33:57 -0000
X-Spam-Check-BY: la.mx.develooper.com
Received-SPF: pass (x1.develooper.com: domain of thoughtstream@gmail.com designates 64.233.184.204 as permitted sender)
Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.204) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Mon, 07 Nov 2005 15:33:49 -0800
Received: by wproxy.gmail.com with SMTP id i5so24838wra for <bug-IO-Prompt@rt.cpan.org>; Mon, 07 Nov 2005 15:33:49 -0800 (PST)
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:reply-to:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:from; b=Xlqo3hI6qdCNYPwq0lKjKndwiap/W1dzUJ1kf7e4f1NsB2BTydEIxypy+opzKhiZzSsl+gPKD3Y7MEwisDzgAdd7v9ChxseENlXun5u8G32Qn6fcJIWe+yUJNofAlBxqAQMHHrhm5llYGWnywlCv8bp13WTGXGA+1Yy1X6fx7s8=
Received: by 10.54.147.10 with SMTP id u10mr105197wrd; Mon, 07 Nov 2005 15:33:48 -0800 (PST)
Received: from ?10.0.1.5? ( [203.129.151.44]) by mx.gmail.com with ESMTP id 15sm151350wrl.2005.11.07.15.33.46; Mon, 07 Nov 2005 15:33:48 -0800 (PST)
Message-ID: <436D15FC.4010608@conway.org>
Date: Sat, 05 Nov 2005 12:28:44 -0800
Reply-To: damian@conway.org
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en, en-us
MIME-Version: 1.0
To: bug-IO-Prompt@rt.cpan.org
Subject: Re: [cpan #15290] -wipe flag has no effect (patch included)
References: <rt-15290-45897.11.2985226335488@cpan.org>
In-Reply-To: <rt-15290-45897.11.2985226335488@cpan.org>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
From: Damian Conway <thoughtstream@gmail.com>
RT-Send-Cc:
X-RT-Original-Encoding: us-ascii
Content-Length: 1195
Show quoted text
> specifying the -wipe flag does not have any effect, the -w flag > without an argument results in an error message "Missing argument for > -w option at -e line 1". > > I've attached three patches against 0.99.2 (to be applied on top of > each other, I wasn't sure whether you'd consider all of them > appropriate), patch 1 enables the long form -wipe, patch 2 enables -w > as wipe if no further arguments are given (if an argument is given, it > is parsed as -while, as per the docs). Patch 3 adds some more DWIMery > and also enables correct cuddling of argument-requiring flags (e.g. > 'prompt -ei,"*"' now does the correct thing instead of ignoring the -i > option).
It was actually a mistake to have -wipe and -wipefirst options. They were supposed to be -clear and -clearfirst (and the actual implementation expected them to be). I've now corrected the docs and the code, so that you get: -w -while <cond> Return true while condition holds -c -clear Clear screen before prompt -f -clearfirst Clear screen before first prompt Thanks for the bug reports and especially for the associated patches. All the best, Damian


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.