Argv
view release on metacpan or search on metacpan
my $self = shift;
my $norm = $self->inpathnorm;
return unless $norm && !ref($norm);
if (CYGWIN) { #for the cygwin shell
s%\\%\\\\%g for @_;
}
return unless MSWIN;
for my $word (@_) {
# If requested, change / for \ in Windows file paths.
# This is necessarily an inexact science.
my @fragments = split ' ', $word;
for (@fragments) {
if (m%^"?/%) {
if (m%(.*/\w+):(.+)%) {
# If it looks like an option specifying a path (/opt:path),
# normalize only the path part.
my($opt, $path) = ($1, $2);
$path =~ s%/%\\%g;
$_ = "$opt:$path";
} else {
# If it contains a slash (any kind) after the initial one
# treat it as a full path. This is where you get into
# ambiguity with combined options (e.g. /E/I/Q/S) which
# could technically be a path. So that's just not allowed
# when path-norming.
my $slashes = tr/\/\\//;
s%/%\\%g if $slashes > 1;
}
} else {
s%/%\\%g;
}
}
$word = "@fragments";
}
}
# Quotes @_ in place against shell expansion. Usually called via autoquote attr
sub quote {
my $self = shift;
for (grep {defined} @_) {
# Hack - allow user to exempt any arg from quoting by prefixing '^'.
next if s%^\^%%;
# Special case - turn internal newlines back to literal \n on Win32
( run in 0.960 second using v1.01-cache-2.11-cpan-b16cb0d3907 )