1 package TAP::Parser::Utils;
5 use vars qw($VERSION @ISA @EXPORT_OK);
8 @EXPORT_OK = qw( split_shell );
12 TAP::Parser::Utils - Internal TAP::Parser utilities
24 use TAP::Parser::Utils qw( split_shell )
25 my @switches = split_shell( $arg );
29 B<FOR INTERNAL USE ONLY!>
35 Shell style argument parsing. Handles backslash escaping, single and
36 double quoted strings but not shell substitutions.
38 Pass one or more strings containing shell escaped arguments. The return
39 value is an array of arguments parsed from the input strings according
40 to (approximate) shell parsing rules. It's legal to pass C<undef> in
41 which case an empty array will be returned. That makes it possible to
43 my @args = split_shell( $ENV{SOME_ENV_VAR} );
45 without worrying about whether the environment variable exists.
47 This is used to split HARNESS_PERL_ARGS into individual switches.
54 for my $switch ( grep defined && length, @_ ) {
55 push @parts, $1 while $switch =~ /
59 | " (?: \\. | [^"] )* "
60 | ' (?: \\. | [^'] )* '
66 s/ \\(.) | ['"] /defined $1 ? $1 : ''/exg;