NixExprs: extract the escape
function and test it
This commit is contained in:
14
src/lib/Hydra/Helper/Escape.pm
Normal file
14
src/lib/Hydra/Helper/Escape.pm
Normal file
@ -0,0 +1,14 @@
|
||||
package Hydra::Helper::Escape;
|
||||
|
||||
use strict;
|
||||
use base qw(Exporter);
|
||||
|
||||
our @EXPORT = qw(escapeString);
|
||||
|
||||
sub escapeString {
|
||||
my ($s) = @_;
|
||||
$s =~ s|\\|\\\\|g;
|
||||
$s =~ s|\"|\\\"|g;
|
||||
$s =~ s|\$|\\\$|g;
|
||||
return "\"" . $s . "\"";
|
||||
}
|
Reference in New Issue
Block a user