NixExprs: extract the escape function and test it

This commit is contained in:
Graham Christensen
2021-03-17 11:07:19 -04:00
parent aeb3d2f44c
commit d62a2c1657
3 changed files with 48 additions and 16 deletions

View 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 . "\"";
}