File: ShellQuoter.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 (40 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (5)
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
39
40
package Net::OpenSSH::ShellQuoter;

use strict;
use warnings;
use Carp;

use Net::OpenSSH::ModuleLoader;

my %alias = (bash  => 'POSIX',
             sh    => 'POSIX',
             ksh   => 'POSIX',
             ash   => 'POSIX',
             dash  => 'POSIX',
             pdksh => 'POSIX',
             mksh  => 'POSIX',
             lksh  => 'POSIX',
             zsh   => 'POSIX',
             fizsh => 'POSIX',
             posh  => 'POSIX',
             fish  => 'fish',
             tcsh  => 'csh');

sub quoter {
    my ($class, $shell) = @_;
    $shell = 'POSIX' unless defined $shell;
    return $shell if ref $shell;
    if ($shell =~ /,/) {
        require Net::OpenSSH::ShellQuoter::Chain;
        return Net::OpenSSH::ShellQuoter::Chain->chain(split /\s*,\s*/, $shell);
    }
    else {
        $shell = $alias{$shell} if defined $alias{$shell};
        $shell =~ /^\w+$/ or croak "bad quoting style $shell";
        my $impl = "Net::OpenSSH::ShellQuoter::$shell";
        _load_module($impl);
        return $impl->new;
    }
}

1;