~ubuntu-branches/ubuntu/wily/libnet-openssh-perl/wily-proposed

« back to all changes in this revision

Viewing changes to lib/Net/OpenSSH/ShellQuoter.pm

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2014-06-14 14:55:17 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140614145517-o61gchpbz76ne5e9
Tags: 0.62-1
* Team upload.
* New upstream release.
* Strip trailing slash from metacpan URLs.
* Update years of upstream copyright.
* Drop spelling.patch, fixed upstream.
* Add patch to improve wording in POD.
* Declare compliance with Debian Policy 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Net::OpenSSH::ShellQuoter;
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
use Carp;
 
6
 
 
7
use Net::OpenSSH::ModuleLoader;
 
8
 
 
9
my %alias = (bash  => 'POSIX',
 
10
             sh    => 'POSIX',
 
11
             ksh   => 'POSIX',
 
12
             ash   => 'POSIX',
 
13
             dash  => 'POSIX',
 
14
             pdksh => 'POSIX',
 
15
             mksh  => 'POSIX',
 
16
             zsh   => 'POSIX',
 
17
             tcsh  => 'csh');
 
18
 
 
19
sub quoter {
 
20
    my ($class, $shell) = @_;
 
21
    $shell = 'POSIX' unless defined $shell;
 
22
    return $shell if ref $shell;
 
23
    if ($shell =~ /,/) {
 
24
        require Net::OpenSSH::ShellQuoter::Chain;
 
25
        return Net::OpenSSH::ShellQuoter::Chain->chain(split /\s*,\s*/, $shell);
 
26
    }
 
27
    else {
 
28
        $shell = $alias{$shell} if defined $alias{$shell};
 
29
        $shell =~ /^\w+$/ or croak "bad quoting style $shell";
 
30
        my $impl = "Net::OpenSSH::ShellQuoter::$shell";
 
31
        _load_module($impl);
 
32
        return $impl->new;
 
33
    }
 
34
}
 
35
 
 
36
1;