[1165] in BarnOwl Developers
[D-O-H] r1113 - trunk/owl
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:41 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@MIT.EDU
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 21 Aug 2008 18:20:16 -0400 (EDT)
Author: nelhage
Date: 2008-08-21 18:20:16 -0400 (Thu, 21 Aug 2008)
New Revision: 1113
Modified:
trunk/owl/perlwrap.pm
Log:
Implement BarnOwl::quote() to fully quote a string against command parsing
Modified: trunk/owl/perlwrap.pm
===================================================================
--- trunk/owl/perlwrap.pm 2008-08-21 22:20:01 UTC (rev 1112)
+++ trunk/owl/perlwrap.pm 2008-08-21 22:20:16 UTC (rev 1113)
@@ -301,6 +301,25 @@
$func->($name, $args{default}, $args{summary}, $args{description});
}
+=head2 quote STRING
+
+Return a version of STRING fully quoted to survive processing by
+BarnOwl's command parser.
+
+=cut
+
+sub quote {
+ my $str = shift;
+ if ($str !~ /'/ && $str !~ /"/) {
+ return "$str";
+ }
+ if ($str !~ /'/) {
+ return "'$str'";
+ }
+ $str =~ s/"/"'"'"/g;
+ return '"' . $str . '"';
+}
+
#####################################################################
#####################################################################