File: Chain.pm

package info (click to toggle)
libnet-openssh-perl 0.84-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: perl: 3,410; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package Net::OpenSSH::ShellQuoter::Chain;

use strict;
use warnings;

use Net::OpenSSH::ShellQuoter;

sub chain {
    my $class = shift;
    my @quoters = map Net::OpenSSH::ShellQuoter->quoter($_), reverse @_;
    my $self = \@quoters;
    bless $self, $class;
    $self;
}

sub quote {
    my ($self, $arg) = @_;
    $arg = $_->quote($arg) for @$self;
    $arg;
}

sub quote_glob {
    my ($self, $arg) = @_;
    if (@$self) {
        $arg = $self->[0]->quote_glob($arg);
        $arg = $self->[$_]->quote($arg) for 1..$#$self;
    }
    $arg
}

sub shell_fragments {
    my $self = shift;
    @$self or return (wantarray ? () : '');
    $self->[-1]->shell_fragments(@_)
}


1;