Hello,
I have been using the great module DBI:Shell via dbish, but I may have come
across a bug. At the least, it did not behave as I expected.
The problem is that when you type the command prefix and it's not part of a
command, DBI::Shell treats whatever you type after the prefix as a command. For
example, the default prefix is /, if I type in "INSERT INTO Table SET
Foo='http://baz.com' WHERE baf=fab/" (terminating my command with /), DBI::Shell
interprets the first / instead of the terminating one.
I am using version 11.2, which according to cpan.org is the most current. I
could not find a bug list, or other resource, to see if this bug was noted or a
patch/fix available.
I was able to make a fix for it, with the help of some other perl gurus. The
fix allows you to escape the prefix by preceding it with a backslash. Below is a diff
of the original DBI/Shell.pm (ver 11.2) and the changed file. It has code to detect
the escaped prefix, and to remove the backslash from the statement before continuing.
This patch works for what I was using it for, but I have not tested it thoroughly, for
all possible command combinations. Also, I only considered the $stmt portion of the
line, not the $cmd, $args_string, or $output.
>$ diff -u ~/orig.Shell.pm Shell.pm
--- /home/rthompson/orig.Shell.pm Thu Oct 17 14:55:25 2002
+++ Shell.pm Thu Oct 17 19:12:12 2002
@@ -353,14 +353,17 @@
if ( $current_line =~ /
^(.*?)
- $prefix
+ (?<!\\)$prefix
(?:(\w*)([^\|>]*))?
((?:\||>>?).+)?
$
/x) {
my ($stmt, $cmd, $args_string, $output) = ($1, $2, $3, $4||'');
- $sh->{current_buffer} .= "$stmt\n" if length $stmt;
+ if (length $stmt) {
+ $stmt =~ s/\\$prefix/$prefix/g;
+ $sh->{current_buffer} .= "$stmt\n";
+ }
$cmd = 'go' if $cmd eq '';
my @args = split ' ', $args_string||'';
Thanks,
=-= Robert Thompson