Changeset 5b75e8b for perlwrap.pm


Ignore:
Timestamp:
Aug 21, 2008, 6:20:16 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
680ada9
Parents:
d5dcd7c
Message:
Implement BarnOwl::quote() to fully quote a string against command parsing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r57cf4f9 r5b75e8b  
    300300        %{$args});
    301301    $func->($name, $args{default}, $args{summary}, $args{description});
     302}
     303
     304=head2 quote STRING
     305
     306Return a version of STRING fully quoted to survive processing by
     307BarnOwl's command parser.
     308
     309=cut
     310
     311sub quote {
     312    my $str = shift;
     313    if ($str !~ /'/ && $str !~ /"/) {
     314        return "$str";
     315    }
     316    if ($str !~ /'/) {
     317        return "'$str'";
     318    }
     319    $str =~ s/"/"'"'"/g;
     320    return '"' . $str . '"';
    302321}
    303322
Note: See TracChangeset for help on using the changeset viewer.