Skip Menu |

This queue is for tickets about the Term-Shell CPAN distribution.

Report information
The Basics
Id: 43390
Status: rejected
Priority: 0/
Queue: Term-Shell

People
Owner: Nobody in particular
Requestors: BARBIE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: (no value)



Subject: single quotes get removed from the parsed line
Not sure where or why exactly this is happening, but using the line() and line_parsed() methods I can see that a raw input of "it's" gets parsed and stored as "its", the single quote is getting deleted. I can overcome this in my application by dealing with the raw line via line(), but it is a bug if you're not passing apostrophes to the handler.
The 'opening quote' (or apostrophe) was eaten when attempting to parse a quoted string and no closing quote was found. This patch fixes that.
--- Shell.pm 2007-02-23 10:37:49.000000000 -0500 +++ Shell.pm.new 2009-10-10 14:07:54.000000000 -0400 @@ -550,10 +550,16 @@ my $o = shift; my $raw = shift; my $quote = shift; + my $quote_end; my $i=1; my $string = ''; my $c; - while($i <= length($raw) and ($c=substr($raw, $i, 1)) ne $quote) { + while($i <= length($raw)) { + $c=substr($raw, $i, 1); + if($c eq '') { + $quote_end = 1; + last; + } if ($c eq '\\') { $string .= $o->process_esc(substr($raw, $i+1, 1), $quote); $i++; @@ -563,6 +569,9 @@ } $i++; } + if ($quote_end) { + return ($quote . $string, $i); + } return ($string, $i); };
Well, from what it seems, line_parse is trying to emulate the behaviour of the UNIX shell and other shells with respect to single-quotes, and this is done by design. If you want to override it you should either escape the single quotes using \, use double quotes or use a different method to parse the line. Can I close this bug? Regards, -- Shlomi Fish
On Tue Oct 16 14:33:52 2012, SHLOMIF wrote: Show quoted text
> Well, from what it seems, line_parse is trying to emulate the behaviour > of the UNIX shell and other shells with respect to single-quotes, and > this is done by design.
Doesn't mean its the right way to do it though :( Show quoted text
> If you want to override it you should either > escape the single quotes using \, use double quotes or use a different > method to parse the line.
Unfortunately my app is a consumer not a creator, so it doesn't get to send Term::Shell the escaped version. I now completely ignore parsed_line as it's unreliable. The code above may fix this particular issue though.
Well, since there's an alternative workaround and this is done by design, I am going to close this ticket as invalid. Thanks for reporting it.