Shell-Guess-0.08/0000755000175000017500000000000013216237257013150 5ustar ollisgollisgShell-Guess-0.08/lib/0000755000175000017500000000000013216237257013716 5ustar ollisgollisgShell-Guess-0.08/lib/Shell/0000755000175000017500000000000013216237257014765 5ustar ollisgollisgShell-Guess-0.08/lib/Shell/Guess.pm0000644000175000017500000004010113216237257016405 0ustar ollisgollisgpackage Shell::Guess; use strict; use warnings; use File::Spec; # TODO: see where we can use P9Y::ProcessTable # ABSTRACT: Make an educated guess about the shell in use our $VERSION = '0.08'; # VERSION sub _win32_getppid { require Win32::Getppid; Win32::Getppid::getppid(); } sub running_shell { if($^O eq 'MSWin32') { my $shell_name = eval { require Win32::Process::List; my $parent_pid = _win32_getppid(); Win32::Process::List->new->{processes}->[0]->{$parent_pid} }; if(defined $shell_name) { if($shell_name =~ /cmd\.exe$/) { return __PACKAGE__->cmd_shell } elsif($shell_name =~ /powershell\.exe$/) { return __PACKAGE__->power_shell } elsif($shell_name =~ /command\.com$/) { return __PACKAGE__->command_shell } } } if($^O eq 'MSWin32') { if($ENV{ComSpec} =~ /cmd\.exe$/) { return __PACKAGE__->cmd_shell } else { return __PACKAGE__->command_shell } } return __PACKAGE__->dcl_shell if $^O eq 'VMS'; return __PACKAGE__->command_shell if $^O eq 'dos'; my $shell = eval { open(my $fh, '<', File::Spec->catfile('', 'proc', getppid, 'comm')) || die; my $command_line = <$fh>; die unless defined $command_line; # don't spew warnings if read failed close $fh; $command_line =~ s/\0.*$//; _unixy_shells($command_line); } || eval { open(my $fh, '<', File::Spec->catfile('', 'proc', getppid, 'cmdline')) || die; my $command_line = <$fh>; die unless defined $command_line; # don't spew warnings if read failed close $fh; $command_line =~ s/\0.*$//; _unixy_shells($command_line); } || eval { require Unix::Process; my $method = $^O eq 'solaris' ? 'comm' : 'command'; my($command) = map { s/\s+.*$//; $_ } Unix::Process->$method(getppid); _unixy_shells($command); }; $shell || __PACKAGE__->login_shell; } sub login_shell { shift; # class ignored my $shell; if($^O eq 'MSWin32') { if(Win32::IsWin95()) { return __PACKAGE__->command_shell } else { return __PACKAGE__->cmd_shell } } return __PACKAGE__->dcl_shell if $^O eq 'VMS'; return __PACKAGE__->command_shell if $^O eq 'dos'; my $username = shift || $ENV{USER} || $ENV{USERNAME} || $ENV{LOGNAME}; if($^O eq 'darwin') { my $command = `dscl . -read /Users/$username UserShell`; $shell = _unixy_shells($command); return $shell if defined $shell; } eval { my $pw_shell = (getpwnam($username))[-1]; $shell = _unixy_shells($pw_shell); $shell = _unixy_shells(readlink $pw_shell) if !defined($shell) && -l $pw_shell; }; $shell = __PACKAGE__->bourne_shell unless defined $shell; return $shell; } sub bash_shell { bless { bash => 1, bourne => 1, unix => 1, name => 'bash', default_location => '/bin/bash' }, __PACKAGE__ } sub bourne_shell { bless { bourne => 1, unix => 1, name => 'bourne', default_location => '/bin/sh' }, __PACKAGE__ } sub c_shell { bless { c => 1, unix => 1, name => 'c', default_location => '/bin/csh' }, __PACKAGE__ } sub cmd_shell { bless { cmd => 1, win32 => 1, name => 'cmd', default_location => 'C:\\Windows\\system32\\cmd.exe' }, __PACKAGE__ } sub command_shell { bless { command => 1, win32 => 1, name => 'command', default_location => 'C:\\Windows\\system32\\command.com' }, __PACKAGE__ } sub dcl_shell { bless { dcl => 1, vms => 1, name => 'dcl' }, __PACKAGE__ } sub fish_shell { bless { fish => 1, unix => 1, name => 'fish' }, __PACKAGE__ } sub korn_shell { bless { korn => 1, bourne => 1, unix => 1, name => 'korn', default_location => '/bin/ksh' }, __PACKAGE__ } sub power_shell { bless { power => 1, win32 => 1, name => 'power' }, __PACKAGE__ } sub tc_shell { bless { c => 1, tc => 1, unix => 1, name => 'tc', default_location => '/bin/tcsh' }, __PACKAGE__ } sub z_shell { bless { z => 1, bourne => 1, unix => 1, name => 'z', default_location => '/bin/zsh' }, __PACKAGE__ } foreach my $type (qw( cmd command dcl bash fish korn c win32 unix vms bourne tc power z )) { eval qq{ sub is_$type { my \$self = ref \$_[0] ? shift : __PACKAGE__->running_shell; \$self->{$type} || 0; } }; die $@ if $@; } sub name { my $self = ref $_[0] ? shift : __PACKAGE__->running_shell; $self->{name}; } sub default_location { my $self = ref $_[0] ? shift : __PACKAGE__->running_shell; $self->{default_location}; } sub _unixy_shells { my $shell = shift; if($shell =~ /tcsh$/) { return __PACKAGE__->tc_shell } elsif($shell =~ /csh$/) { return __PACKAGE__->c_shell } elsif($shell =~ /ksh$/) { return __PACKAGE__->korn_shell } elsif($shell =~ /bash$/) { return __PACKAGE__->bash_shell } elsif($shell =~ /zsh$/) { return __PACKAGE__->z_shell } elsif($shell =~ /fish$/) { return __PACKAGE__->fish_shell } elsif($shell =~ /sh$/) { return __PACKAGE__->bourne_shell } else { return; } } 1; __END__ =pod =encoding UTF-8 =head1 NAME Shell::Guess - Make an educated guess about the shell in use =head1 VERSION version 0.08 =head1 SYNOPSIS guessing shell which called the Perl script: use Shell::Guess; my $shell = Shell::Guess->running_shell; if($shell->is_c) { print "setenv FOO bar\n"; } elsif($shell->is_bourne) { print "export FOO=bar\n"; } guessing the current user's login shell: use Shell::Guess; my $shell = Shell::Guess->login_shell; print $shell->name, "\n"; guessing an arbitrary user's login shell: use Shell::Guess; my $shell = Shell::Guess->login_shell('bob'); print $shell->name, "\n"; =head1 DESCRIPTION Shell::Guess makes a reasonably aggressive attempt to determine the shell being employed by the user, either the shell that executed the perl script directly (the "running" shell), or the users' login shell (the "login" shell). It does this by a variety of means available to it, depending on the platform that it is running on. =over 4 =item * getpwent On UNIXy systems with getpwent, that can be used to determine the login shell. =item * dscl Under Mac OS X getpwent will typically not provide any useful information, so the dscl command is used instead. =item * proc file systems On UNIXy systems with a proc filesystems (such as Linux), Shell::Guess will attempt to use that to determine the running shell. =item * ps On UNIXy systems without a proc filesystem, Shell::Guess will use the ps command to determine the running shell. =item * L and L On Windows if these modules are installed they will be used to determine the running shell. This method can differentiate between PowerShell, C and C. =item * ComSpec If the above method is inconclusive, the ComSpec environment variable will be consulted to differentiate between C or C (PowerShell cannot be detected in this manner). =item * reasonable defaults If the running or login shell cannot be otherwise determined, a reasonable default for your platform will be used as a fallback. Under OpenVMS this is dcl, Windows 95/98 and MS-DOS this is command.com and Windows NT/2000/XP/Vista/7 this is cmd.exe. UNIXy platforms fallback to bourne shell. =back The intended use of this module is to enable a Perl developer to write a script that generates shell configurations for the calling shell so they can be imported back into the calling shell using C and backticks or C. For example, if your script looks like this: #!/usr/bin/perl use Shell::Guess; my $shell = Shell::Guess->running_shell; if($shell->is_bourne) { print "export FOO=bar\n"; } else($shell->is_c) { print "setenv FOO bar\n"; } else { die "I don't support ", $shell->name, " shell"; } You can then import FOO into your bash or c shell like this: % eval `perl script.pl` or, you can write the output to a configuration file and source it: % perl script.pl > foo.sh % source foo.sh L provides a portable interface for generating such shell configurations, and is designed to work with this module. =head1 CLASS METHODS These class methods return an instance of Shell::Guess, which can then be interrogated by the instance methods in the next section below. =head2 running_shell my $shell = Shell::Guess->running_shell; Returns an instance of Shell::Guess based on the shell which directly started the current Perl script. If the running shell cannot be determined, it will return the login shell. =head2 login_shell my $shell = Shell::Guess->login_shell; my $shell = Shell::Guess->login_shell( $username ) Returns an instance of Shell::Guess for the given user. If no username is specified then the current user will be used. If no shell can be guessed then a reasonable fallback will be chosen based on your platform. =head2 bash_shell my $shell = Shell::Guess->bash_shell; Returns an instance of Shell::Guess for bash. The following instance methods will return: =over 4 =item * $shell-Ename = bash =item * $shell-Eis_bash = 1 =item * $shell-Eis_bourne = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/bash =back All other instance methods will return false =head2 bourne_shell my $shell = Shell::Guess->bourne_shell; Returns an instance of Shell::Guess for the bourne shell. The following instance methods will return: =over 4 =item * $shell-Ename = bourne =item * $shell-Eis_bourne = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/sh =back All other instance methods will return false =head2 c_shell my $shell = Shell::Guess->c_shell; Returns an instance of Shell::Guess for c shell. The following instance methods will return: =over 4 =item * $shell-Ename = c =item * $shell-Eis_c = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/csh =back All other instance methods will return false =head2 cmd_shell my $shell = Shell::Guess->cmd_shell; Returns an instance of Shell::Guess for the Windows NT cmd shell (cmd.exe). The following instance methods will return: =over 4 =item * $shell-Ename = cmd =item * $shell-Eis_cmd = 1 =item * $shell-Eis_win32 = 1 =item * $shell-Edefault_location = C:\Windows\system32\cmd.exe =back All other instance methods will return false =head2 command_shell my $shell = Shell::Guess->command_shell; Returns an instance of Shell::Guess for the Windows 95 command shell (command.com). The following instance methods will return: =over 4 =item * $shell-Ename = command =item * $shell-Eis_command = 1 =item * $shell-Eis_win32 = 1 =item * $shell-Edefault_location = C:\Windows\system32\command.com =back All other instance methods will return false =head2 dcl_shell my $shell = Shell::Guess->dcl_shell; Returns an instance of Shell::Guess for the OpenVMS dcl shell. The following instance methods will return: =over 4 =item * $shell-Ename = dcl =item * $shell-Eis_dcl = 1 =item * $shell-Eis_vms = 1 =back All other instance methods will return false =head2 fish_shell my $shell = Shell::Guess->fish_shell; Returns an instance of Shell::Guess for the fish shell. The following instance methods will return: =over 4 =item * $shell-Ename = fish =item * $shell-Eis_fish = 1 =item * $shell-Eis_unix = 1 =back =head2 korn_shell my $shell = Shell::Guess->korn_shell; Returns an instance of Shell::Guess for the korn shell. The following instance methods will return: =over 4 =item * $shell-Ename = korn =item * $shell-Eis_korn = 1 =item * $shell-Eis_bourne = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/ksh =back All other instance methods will return false =head2 power_shell my $shell = Shell::Guess->power_shell; Returns an instance of Shell::Guess for Windows PowerShell. The following instance methods will return: =over 4 =item * $shell-Ename = power =item * $shell-Eis_power = 1 =item * $shell-Eis_win32 = 1 =back All other instance methods will return false =head2 tc_shell my $shell = Shell::Guess->tc_shell; Returns an instance of Shell::Guess for tcsh. The following instance methods will return: =over 4 =item * $shell-Ename = tc =item * $shell-Eis_tc = 1 =item * $shell-Eis_c = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/tcsh =back All other instance methods will return false =head2 z_shell my $shell = Shell::Guess->z_shell Returns an instance of Shell::Guess for zsh. The following instance methods will return: =over 4 =item * $shell-Ename = z =item * $shell-Eis_z = 1 =item * $shell-Eis_bourne = 1 =item * $shell-Eis_unix = 1 =item * $shell-Edefault_location = /bin/zsh =back All other instance methods will return false =head1 INSTANCE METHODS The normal way to call these is by calling them on the result of either I or I, but they can also be called as class methods, in which case the currently running shell will be used, so Shell::Guess->is_bourne is the same as Shell::Guess->running_shell->is_bourne =head2 is_bash my $bool = $shell->is_bash; Returns true if the shell is bash. =head2 is_bourne my $bool = $shell->is_bourne; Returns true if the shell is the bourne shell, or a shell which supports bourne syntax (e.g. bash or korn). =head2 is_c my $bool = $shell->is_c; Returns true if the shell is csh, or a shell which supports csh syntax (e.g. tcsh). =head2 is_cmd my $bool = $shell->is_cmd; Returns true if the shell is the Windows command.com shell. =head2 is_command my $bool = $shell->is_command; Returns true if the shell is the Windows cmd.com shell. =head2 is_dcl my $bool = $shell->is_dcl; Returns true if the shell is the OpenVMS dcl shell. =head2 is_fish my $bool = $shell->is_fish; Returns true if the shell is Fish shell. =head2 is_korn my $bool = $shell->is_korn; Returns true if the shell is the korn shell. =head2 is_power my $bool = $shell->is_power; Returns true if the shell is Windows PowerShell. =head2 is_tc my $bool = $shell->is_tc; Returns true if the shell is tcsh. =head2 is_unix my $bool = $shell->is_unix; Returns true if the shell is traditionally a UNIX shell (e.g. bourne, bash, korn) =head2 is_vms my $bool = $shell->is_vms; Returns true if the shell is traditionally an OpenVMS shell (e.g. dcl) =head2 is_win32 my $bool = $shell->is_win32; Returns true if the shell is traditionally a Windows shell (command.com, cmd.exe) =head2 is_z my $bool = $shell->is_z; Returns true if the shell is zsh =head2 name my $name = $shell->name; Returns the name of the shell. =head2 default_location my $location = $shell->default_location; The usual location for this shell, for example /bin/sh for bourne shell and /bin/csh for c shell. May not be defined for all shells. =head1 CAVEATS Shell::Guess shouldn't ever die or crash, instead it will attempt to make a guess or use a fallback about either the login or running shell even on unsupported operating systems. The fallback is the most common shell on the particular platform that you are using, so on UNIXy platforms the fallback is bourne, and on OpenVMS the fallback is dcl. These are the operating systems that have been tested in development and are most likely to guess reliably. =over 4 =item * Linux =item * Cygwin =item * FreeBSD =item * Mac OS X =item * Windows (Strawberry Perl) =item * Solaris (x86) =item * MS-DOS (djgpp) =item * OpenVMS Always detected as dcl (a more nuanced view of OpenVMS is probably possible, patches welcome). =back UNIXy platforms without a proc filesystem will use L if installed, which will execute ps to determine the running shell. It is pretty easy to fool the -Erunning_shell method by using fork, or if your Perl script is not otherwise being directly executed by the shell. Patches are welcome to make other platforms work more reliably. =head1 AUTHOR Author: Graham Ollis Eplicease@cpan.orgE Contributors: Buddy Burden (BAREFOOT) Julien Fiegehenn (SIMBABQUE) =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Shell-Guess-0.08/author.yml0000644000175000017500000000046313216237257015200 0ustar ollisgollisg--- pod_spelling_system: stopwords: - login - OpenVMS - bourne - UNIXy - dcl - korn - cmd.exe - command.com - ComSpec - cmd - tc - PowerShell - prereqs - FreeBSD - ps - dscl - proc - exe - Fiegehenn - Julien - SIMBABQUE Shell-Guess-0.08/Makefile.PL0000644000175000017500000000520313216237257015122 0ustar ollisgollisguse strict; use warnings; BEGIN { unless(eval q{ use 5.006; 1}) { print "Perl 5.006 or better required\n"; exit; } } # This file was automatically generated by Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.25. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Make an educated guess about the shell in use", "AUTHOR" => "Graham Ollis ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Shell-Guess", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "Shell::Guess", "PM" => { "lib/Shell/Guess.pm" => "\$(INST_LIB)/Shell/Guess.pm" }, "PREREQ_PM" => {}, "TEST_REQUIRES" => { "Test::More" => "0.94" }, "VERSION" => "0.08", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Test::More" => "0.94" ); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.033 if ( ( $^O ne 'dos' && $^O ne 'VMS' && $^O ne 'MSWin32' && eval { getppid; 1 } ) && !do { require File::Spec; -e File::Spec->catfile( '', 'proc', getppid, 'cmdline' ) } ) { requires('Unix::Process'); } # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.033 if ( $^O eq 'MSWin32' ) { requires('Win32::Getppid'); requires('Win32::Process::List'); } unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.033 sub _add_prereq { my ( $mm_key, $module, $version_or_range ) = @_; $version_or_range ||= 0; warn "$module already exists in $mm_key (at version $WriteMakefileArgs{$mm_key}{$module}) -- need to do a sane metamerge!" if exists $WriteMakefileArgs{$mm_key}{$module} and $WriteMakefileArgs{$mm_key}{$module} ne '0' and $WriteMakefileArgs{$mm_key}{$module} ne $version_or_range; warn "$module already exists in FallbackPrereqs (at version $WriteMakefileArgs{$mm_key}{$module}) -- need to do a sane metamerge!" if exists $FallbackPrereqs{$module} and $FallbackPrereqs{$module} ne '0' and $FallbackPrereqs{$module} ne $version_or_range; $WriteMakefileArgs{$mm_key}{$module} = $FallbackPrereqs{$module} = $version_or_range; return; } sub requires { goto &runtime_requires } sub runtime_requires { my ( $module, $version_or_range ) = @_; _add_prereq( PREREQ_PM => $module, $version_or_range ); }Shell-Guess-0.08/xt/0000755000175000017500000000000013216237257013603 5ustar ollisgollisgShell-Guess-0.08/xt/release/0000755000175000017500000000000013216237257015223 5ustar ollisgollisgShell-Guess-0.08/xt/release/fixme.t0000644000175000017500000000062013216237257016516 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Fixme' unless eval q{ use Test::Fixme 0.14; 1 }; }; use Test::Fixme 0.07; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); run_tests( match => qr/FIXME/, where => [ grep { -e $_ } qw( bin lib t Makefile.PL Build.PL )], warn => 1, ); Shell-Guess-0.08/xt/release/changes.t0000644000175000017500000000111513216237257017016 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::CPAN::Changes' unless eval q{ use Test::CPAN::Changes; 1 }; }; use Test::CPAN::Changes; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); do { my $old = \&Test::Builder::carp; my $new = sub { my($self, @messages) = @_; return if $messages[0] =~ /^Date ".*" is not in the recommend format/; $old->($self, @messages); }; no warnings 'redefine'; *Test::Builder::carp = $new; }; changes_file_ok; done_testing; Shell-Guess-0.08/xt/author/0000755000175000017500000000000013216237257015105 5ustar ollisgollisgShell-Guess-0.08/xt/author/no_tabs.t0000644000175000017500000000052413216237257016720 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::NoTabs' unless eval q{ use Test::NoTabs; 1 }; }; use Test::NoTabs; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); Shell-Guess-0.08/xt/author/pod_spelling_common.t0000644000175000017500000000135213216237257021322 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod::Spelling::CommonMistakes' unless eval q{ use Test::Pod::Spelling::CommonMistakes; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML qw( LoadFile ); 1 }; }; use Test::Pod::Spelling::CommonMistakes; use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_spelling_common}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); # TODO: test files in bin too. all_pod_files_ok; Shell-Guess-0.08/xt/author/pod_coverage.t0000644000175000017500000000363013216237257017731 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires 5.010 or better' unless $] >= 5.010; plan skip_all => 'test requires Test::Pod::Coverage' unless eval q{ use Test::Pod::Coverage; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; }; use Test::Pod::Coverage; use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_coverage}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); my @private_classes; my %private_methods; push @{ $config->{pod_coverage}->{private} }, 'Alien::.*::Install::Files#Inline'; foreach my $private (@{ $config->{pod_coverage}->{private} }) { my($class,$method) = split /#/, $private; if(defined $class && $class ne '') { my $regex = eval 'qr{^' . $class . '$}'; if(defined $method && $method ne '') { push @private_classes, { regex => $regex, method => $method }; } else { push @private_classes, { regex => $regex, all => 1 }; } } elsif(defined $method && $method ne '') { $private_methods{$_} = 1 for split /,/, $method; } } my @classes = all_modules; plan tests => scalar @classes; foreach my $class (@classes) { SKIP: { my($is_private_class) = map { 1 } grep { $class =~ $_->{regex} && $_->{all} } @private_classes; skip "private class: $class", 1 if $is_private_class; my %methods = map {; $_ => 1 } map { split /,/, $_->{method} } grep { $class =~ $_->{regex} } @private_classes; $methods{$_} = 1 for keys %private_methods; my $also_private = eval 'qr{^' . join('|', keys %methods ) . '$}'; pod_coverage_ok $class, { also_private => [$also_private] }; }; } Shell-Guess-0.08/xt/author/strict.t0000644000175000017500000000103313216237257016577 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Strict' unless eval q{ use Test::Strict; 1 }; }; use Test::Strict; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); unshift @Test::Strict::MODULES_ENABLING_STRICT, 'ozo', 'Test2::Bundle::SIPS', 'Test2::V0', 'Test2::Bundle::Extended'; note "enabling strict = $_" for @Test::Strict::MODULES_ENABLING_STRICT; all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); Shell-Guess-0.08/xt/author/eol.t0000644000175000017500000000051213216237257016047 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::EOL' unless eval q{ use Test::EOL; 1 }; }; use Test::EOL; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok(grep { -e $_ } qw( bin lib t Makefile.PL )); Shell-Guess-0.08/xt/author/version.t0000644000175000017500000000214413216237257016760 0ustar ollisgollisguse strict; use warnings; use Test::More; use FindBin (); BEGIN { plan skip_all => "test requires Test::Version 2.00" unless eval q{ use Test::Version 2.00 qw( version_all_ok ), { has_version => 1, filename_match => sub { $_[0] !~ m{/(ConfigData|Install/Files)\.pm$} }, }; 1 }; plan skip_all => "test requires Path::Class" unless eval q{ use Path::Class qw( file dir ); 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; } use YAML qw( LoadFile ); use FindBin; use File::Spec; plan skip_all => "test not built yet (run dzil test)" unless -e dir( $FindBin::Bin)->parent->parent->file('Makefile.PL') || -e dir( $FindBin::Bin)->parent->parent->file('Build.PL'); my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; if($config->{version}->{dir}) { note "using dir " . $config->{version}->{dir} } version_all_ok($config->{version}->{dir} ? ($config->{version}->{dir}) : ()); done_testing; Shell-Guess-0.08/xt/author/pod_spelling_system.t0000644000175000017500000000237213216237257021361 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Spelling' unless eval q{ use Test::Spelling; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; }; use Test::Spelling; use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_spelling_system}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); add_stopwords(@{ $config->{pod_spelling_system}->{stopwords} }); add_stopwords(qw( Plicease stdout stderr stdin subref loopback username os Ollis Mojolicious plicease CPAN reinstall TODO filename filenames login callback callbacks standalone VMS hostname hostnames TCP UDP IP API MSWin32 OpenBSD FreeBSD NetBSD unencrypted WebSocket WebSockets timestamp timestamps poney BackPAN portably RedHat AIX BSD XS FFI perlish optimizations subdirectory RESTful SQLite JavaScript dir plugins munge jQuery namespace PDF PDFs usernames DBI pluggable APIs SSL JSON YAML uncommented Solaris OpenVMS URI URL CGI )); all_pod_files_spelling_ok; Shell-Guess-0.08/xt/author/pod.t0000644000175000017500000000047413216237257016061 0ustar ollisgollisguse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod' unless eval q{ use Test::Pod; 1 }; }; use Test::Pod; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_pod_files_ok( grep { -e $_ } qw( bin lib )); Shell-Guess-0.08/corpus/0000755000175000017500000000000013216237257014463 5ustar ollisgollisgShell-Guess-0.08/corpus/print_guess.pl0000644000175000017500000000013413216237257017360 0ustar ollisgollisguse strict; use warnings; use Shell::Guess; print Shell::Guess->running_shell->name, "\n"; Shell-Guess-0.08/META.yml0000644000175000017500000000153513216237257014425 0ustar ollisgollisg--- abstract: 'Make an educated guess about the shell in use' author: - 'Graham Ollis ' build_requires: Test::More: '0.94' perl: '5.006' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.006' dynamic_config: '1' generated_by: 'Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Shell-Guess requires: perl: '5.006' resources: bugtracker: https://github.com/plicease/Shell-Guess/issues homepage: https://metacpan.org/pod/Shell::Guess repository: git://github.com/plicease/Shell-Guess.git version: '0.08' x_contributors: - 'Graham Ollis ' - 'Buddy Burden (BAREFOOT)' - 'Julien Fiegehenn (SIMBABQUE)' x_serialization_backend: 'YAML::Tiny version 1.70' x_use_unsafe_inc: 0 Shell-Guess-0.08/dist.ini0000644000175000017500000000227613216237257014623 0ustar ollisgollisgname = Shell-Guess author = Graham Ollis license = Perl_5 copyright_holder = Graham Ollis copyright_year = 2012 version = 0.08 [@Author::Plicease] :version = 2.25 release_tests = 1 travis_status = 1 diag = +Unix::Process diag = +Win32::Getppid diag = +Win32::Process::List [RemovePrereqs] ; comes with Perl remove = strict remove = warnings remove = lib remove = File::Spec remove = FindBin ; optional remove = Unix::Process remove = Win32::Getppid remove = Win32::Process::List ; part of the testlib remove = FakeLogin [Author::Plicease::Upload] [Author::Plicease::Thanks] current = Graham Ollis contributor = Buddy Burden (BAREFOOT) contributor = Julien Fiegehenn (SIMBABQUE) [Meta::Dynamic::Config] [DynamicPrereqs / DynamicPrereqsUnixWithoutProc] -condition = ($^O ne 'dos' && $^O ne 'VMS' && $^O ne 'MSWin32' && eval { getppid; 1 }) && ! do { require File::Spec; -e File::Spec->catfile('', 'proc', getppid, 'cmdline') } -body = requires('Unix::Process'); [DynamicPrereqs / DynamicPrereqsWinblows] -condition = $^O eq 'MSWin32' -body = requires('Win32::Getppid'); -body = requires('Win32::Process::List'); Shell-Guess-0.08/META.json0000644000175000017500000000357013216237257014576 0ustar ollisgollisg{ "abstract" : "Make an educated guess about the shell in use", "author" : [ "Graham Ollis " ], "dynamic_config" : 1, "generated_by" : "Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Shell-Guess", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "perl" : "5.006" } }, "develop" : { "requires" : { "Test::CPAN::Changes" : "0", "Test::EOL" : "0", "Test::Fixme" : "0.07", "Test::More" : "0.94", "Test::NoTabs" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0", "Test::Strict" : "0", "YAML" : "0" } }, "runtime" : { "requires" : { "perl" : "5.006" } }, "test" : { "requires" : { "Test::More" : "0.94", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/plicease/Shell-Guess/issues" }, "homepage" : "https://metacpan.org/pod/Shell::Guess", "repository" : { "type" : "git", "url" : "git://github.com/plicease/Shell-Guess.git", "web" : "https://github.com/plicease/Shell-Guess" } }, "version" : "0.08", "x_contributors" : [ "Graham Ollis ", "Buddy Burden (BAREFOOT)", "Julien Fiegehenn (SIMBABQUE)" ], "x_serialization_backend" : "Cpanel::JSON::XS version 3.0239", "x_use_unsafe_inc" : 0 } Shell-Guess-0.08/README0000644000175000017500000002645213216237257014041 0ustar ollisgollisgNAME Shell::Guess - Make an educated guess about the shell in use VERSION version 0.08 SYNOPSIS guessing shell which called the Perl script: use Shell::Guess; my $shell = Shell::Guess->running_shell; if($shell->is_c) { print "setenv FOO bar\n"; } elsif($shell->is_bourne) { print "export FOO=bar\n"; } guessing the current user's login shell: use Shell::Guess; my $shell = Shell::Guess->login_shell; print $shell->name, "\n"; guessing an arbitrary user's login shell: use Shell::Guess; my $shell = Shell::Guess->login_shell('bob'); print $shell->name, "\n"; DESCRIPTION Shell::Guess makes a reasonably aggressive attempt to determine the shell being employed by the user, either the shell that executed the perl script directly (the "running" shell), or the users' login shell (the "login" shell). It does this by a variety of means available to it, depending on the platform that it is running on. * getpwent On UNIXy systems with getpwent, that can be used to determine the login shell. * dscl Under Mac OS X getpwent will typically not provide any useful information, so the dscl command is used instead. * proc file systems On UNIXy systems with a proc filesystems (such as Linux), Shell::Guess will attempt to use that to determine the running shell. * ps On UNIXy systems without a proc filesystem, Shell::Guess will use the ps command to determine the running shell. * Win32::Getppid and Win32::Process::List On Windows if these modules are installed they will be used to determine the running shell. This method can differentiate between PowerShell, command.com and cmd.exe. * ComSpec If the above method is inconclusive, the ComSpec environment variable will be consulted to differentiate between command.com or cmd.exe (PowerShell cannot be detected in this manner). * reasonable defaults If the running or login shell cannot be otherwise determined, a reasonable default for your platform will be used as a fallback. Under OpenVMS this is dcl, Windows 95/98 and MS-DOS this is command.com and Windows NT/2000/XP/Vista/7 this is cmd.exe. UNIXy platforms fallback to bourne shell. The intended use of this module is to enable a Perl developer to write a script that generates shell configurations for the calling shell so they can be imported back into the calling shell using eval and backticks or source. For example, if your script looks like this: #!/usr/bin/perl use Shell::Guess; my $shell = Shell::Guess->running_shell; if($shell->is_bourne) { print "export FOO=bar\n"; } else($shell->is_c) { print "setenv FOO bar\n"; } else { die "I don't support ", $shell->name, " shell"; } You can then import FOO into your bash or c shell like this: % eval `perl script.pl` or, you can write the output to a configuration file and source it: % perl script.pl > foo.sh % source foo.sh Shell::Config::Generate provides a portable interface for generating such shell configurations, and is designed to work with this module. CLASS METHODS These class methods return an instance of Shell::Guess, which can then be interrogated by the instance methods in the next section below. running_shell my $shell = Shell::Guess->running_shell; Returns an instance of Shell::Guess based on the shell which directly started the current Perl script. If the running shell cannot be determined, it will return the login shell. login_shell my $shell = Shell::Guess->login_shell; my $shell = Shell::Guess->login_shell( $username ) Returns an instance of Shell::Guess for the given user. If no username is specified then the current user will be used. If no shell can be guessed then a reasonable fallback will be chosen based on your platform. bash_shell my $shell = Shell::Guess->bash_shell; Returns an instance of Shell::Guess for bash. The following instance methods will return: * $shell->name = bash * $shell->is_bash = 1 * $shell->is_bourne = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/bash All other instance methods will return false bourne_shell my $shell = Shell::Guess->bourne_shell; Returns an instance of Shell::Guess for the bourne shell. The following instance methods will return: * $shell->name = bourne * $shell->is_bourne = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/sh All other instance methods will return false c_shell my $shell = Shell::Guess->c_shell; Returns an instance of Shell::Guess for c shell. The following instance methods will return: * $shell->name = c * $shell->is_c = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/csh All other instance methods will return false cmd_shell my $shell = Shell::Guess->cmd_shell; Returns an instance of Shell::Guess for the Windows NT cmd shell (cmd.exe). The following instance methods will return: * $shell->name = cmd * $shell->is_cmd = 1 * $shell->is_win32 = 1 * $shell->default_location = C:\Windows\system32\cmd.exe All other instance methods will return false command_shell my $shell = Shell::Guess->command_shell; Returns an instance of Shell::Guess for the Windows 95 command shell (command.com). The following instance methods will return: * $shell->name = command * $shell->is_command = 1 * $shell->is_win32 = 1 * $shell->default_location = C:\Windows\system32\command.com All other instance methods will return false dcl_shell my $shell = Shell::Guess->dcl_shell; Returns an instance of Shell::Guess for the OpenVMS dcl shell. The following instance methods will return: * $shell->name = dcl * $shell->is_dcl = 1 * $shell->is_vms = 1 All other instance methods will return false fish_shell my $shell = Shell::Guess->fish_shell; Returns an instance of Shell::Guess for the fish shell. The following instance methods will return: * $shell->name = fish * $shell->is_fish = 1 * $shell->is_unix = 1 korn_shell my $shell = Shell::Guess->korn_shell; Returns an instance of Shell::Guess for the korn shell. The following instance methods will return: * $shell->name = korn * $shell->is_korn = 1 * $shell->is_bourne = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/ksh All other instance methods will return false power_shell my $shell = Shell::Guess->power_shell; Returns an instance of Shell::Guess for Windows PowerShell. The following instance methods will return: * $shell->name = power * $shell->is_power = 1 * $shell->is_win32 = 1 All other instance methods will return false tc_shell my $shell = Shell::Guess->tc_shell; Returns an instance of Shell::Guess for tcsh. The following instance methods will return: * $shell->name = tc * $shell->is_tc = 1 * $shell->is_c = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/tcsh All other instance methods will return false z_shell my $shell = Shell::Guess->z_shell Returns an instance of Shell::Guess for zsh. The following instance methods will return: * $shell->name = z * $shell->is_z = 1 * $shell->is_bourne = 1 * $shell->is_unix = 1 * $shell->default_location = /bin/zsh All other instance methods will return false INSTANCE METHODS The normal way to call these is by calling them on the result of either running_shell or login_shell, but they can also be called as class methods, in which case the currently running shell will be used, so Shell::Guess->is_bourne is the same as Shell::Guess->running_shell->is_bourne is_bash my $bool = $shell->is_bash; Returns true if the shell is bash. is_bourne my $bool = $shell->is_bourne; Returns true if the shell is the bourne shell, or a shell which supports bourne syntax (e.g. bash or korn). is_c my $bool = $shell->is_c; Returns true if the shell is csh, or a shell which supports csh syntax (e.g. tcsh). is_cmd my $bool = $shell->is_cmd; Returns true if the shell is the Windows command.com shell. is_command my $bool = $shell->is_command; Returns true if the shell is the Windows cmd.com shell. is_dcl my $bool = $shell->is_dcl; Returns true if the shell is the OpenVMS dcl shell. is_fish my $bool = $shell->is_fish; Returns true if the shell is Fish shell. is_korn my $bool = $shell->is_korn; Returns true if the shell is the korn shell. is_power my $bool = $shell->is_power; Returns true if the shell is Windows PowerShell. is_tc my $bool = $shell->is_tc; Returns true if the shell is tcsh. is_unix my $bool = $shell->is_unix; Returns true if the shell is traditionally a UNIX shell (e.g. bourne, bash, korn) is_vms my $bool = $shell->is_vms; Returns true if the shell is traditionally an OpenVMS shell (e.g. dcl) is_win32 my $bool = $shell->is_win32; Returns true if the shell is traditionally a Windows shell (command.com, cmd.exe) is_z my $bool = $shell->is_z; Returns true if the shell is zsh name my $name = $shell->name; Returns the name of the shell. default_location my $location = $shell->default_location; The usual location for this shell, for example /bin/sh for bourne shell and /bin/csh for c shell. May not be defined for all shells. CAVEATS Shell::Guess shouldn't ever die or crash, instead it will attempt to make a guess or use a fallback about either the login or running shell even on unsupported operating systems. The fallback is the most common shell on the particular platform that you are using, so on UNIXy platforms the fallback is bourne, and on OpenVMS the fallback is dcl. These are the operating systems that have been tested in development and are most likely to guess reliably. * Linux * Cygwin * FreeBSD * Mac OS X * Windows (Strawberry Perl) * Solaris (x86) * MS-DOS (djgpp) * OpenVMS Always detected as dcl (a more nuanced view of OpenVMS is probably possible, patches welcome). UNIXy platforms without a proc filesystem will use Unix::Process if installed, which will execute ps to determine the running shell. It is pretty easy to fool the ->running_shell method by using fork, or if your Perl script is not otherwise being directly executed by the shell. Patches are welcome to make other platforms work more reliably. AUTHOR Author: Graham Ollis Contributors: Buddy Burden (BAREFOOT) Julien Fiegehenn (SIMBABQUE) COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Shell-Guess-0.08/MANIFEST0000644000175000017500000000153513216237257014305 0ustar ollisgollisg# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.010. Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README author.yml corpus/print_guess.pl dist.ini lib/Shell/Guess.pm t/00_diag.t t/lib/FakeLogin.pm t/shell_guess__bash.t t/shell_guess__bourne.t t/shell_guess__c.t t/shell_guess__cmd.t t/shell_guess__command.t t/shell_guess__dcl.t t/shell_guess__fish.t t/shell_guess__guess_login.t t/shell_guess__guess_running.t t/shell_guess__korn.t t/shell_guess__os_dos.t t/shell_guess__os_proc.t t/shell_guess__os_vms.t t/shell_guess__os_win32.t t/shell_guess__power.t t/shell_guess__tc.t t/shell_guess__z.t xt/author/eol.t xt/author/no_tabs.t xt/author/pod.t xt/author/pod_coverage.t xt/author/pod_spelling_common.t xt/author/pod_spelling_system.t xt/author/strict.t xt/author/version.t xt/release/changes.t xt/release/fixme.t Shell-Guess-0.08/LICENSE0000644000175000017500000004365513216237257014172 0ustar ollisgollisgThis software is copyright (c) 2012 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Graham Ollis. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Graham Ollis. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Shell-Guess-0.08/t/0000755000175000017500000000000013216237257013413 5ustar ollisgollisgShell-Guess-0.08/t/lib/0000755000175000017500000000000013216237257014161 5ustar ollisgollisgShell-Guess-0.08/t/lib/FakeLogin.pm0000644000175000017500000000027313216237257016360 0ustar ollisgollisgpackage FakeLogin; use strict; use warnings; use Shell::Guess; do { no warnings 'redefine'; sub Shell::Guess::login_shell { return Shell::Guess->bourne_shell(); } }; 1; Shell-Guess-0.08/t/shell_guess__os_win32.t0000644000175000017500000000161113216237257017776 0ustar ollisgollisguse strict; use warnings; use Test::More; plan skip_all => 'windows only test' unless $^O eq 'MSWin32'; plan tests => 4; my $fake_is_win95 = 0; eval q{ package Win32; $INC{'Win32.pm'} = __FILE__; no warnings; sub IsWin95 { $fake_is_win95 ? 1 : 0 } sub IsWinNT { $fake_is_win95 ? 0 : 1 } }; die $@ if $@; eval q{ use Shell::Guess }; die $@ if $@; do { local $ENV{ComSpec} = 'C:\\Windows\\system32\\cmd.exe'; is eval { Shell::Guess->running_shell->is_cmd }, 1, "running cmd.exe"; diag $@ if $@; }; do { local $ENV{ComSpec} = 'C:\\Windows\\system32\\command.exe'; is eval { Shell::Guess->running_shell->is_command }, 1, "running command.com"; diag $@ if $@; }; $fake_is_win95 = 1; is eval { Shell::Guess->login_shell->is_command }, 1, 'login command.com'; diag $@ if $@; $fake_is_win95 = 0; is eval { Shell::Guess->login_shell->is_cmd }, 1, 'login cmd.exe'; diag $@ if $@;Shell-Guess-0.08/t/shell_guess__cmd.t0000644000175000017500000000217513216237257017104 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->cmd_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 1, "cmd = 1"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 1, "win32 = 1"; diag $@ if $@; is eval { $shell->is_unix }, 0, "unix = 0"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, 'C:\\Windows\\system32\\cmd.exe', 'default_location = C:\\Windows\\system32\\cmd.exe'; Shell-Guess-0.08/t/shell_guess__command.t0000644000175000017500000000221113216237257017746 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->command_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 1, "command = 1"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 1, "win32 = 1"; diag $@ if $@; is eval { $shell->is_unix }, 0, "unix = 0"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, 'C:\\Windows\\system32\\command.com', 'default_location = C:\\Windows\\system32\\command.com'; Shell-Guess-0.08/t/shell_guess__os_vms.t0000644000175000017500000000044413216237257017644 0ustar ollisgollisguse strict; use warnings; use Test::More; use Shell::Guess; plan skip_all => 'VMS only test' unless $^O eq 'VMS'; plan tests => 2; is eval { Shell::Guess->running_shell->is_dcl }, 1, "running dcl"; diag $@ if $@; is eval { Shell::Guess->login_shell->is_dcl }, 1, "login dcl"; diag $@ if $@;Shell-Guess-0.08/t/shell_guess__guess_login.t0000644000175000017500000000050013216237257020645 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 3; use Shell::Guess; my $shell = eval { Shell::Guess->login_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; ok $shell->is_win32 || $shell->is_unix || $shell->is_vms, 'shell is one of win32 unix or vms environment'; ok $shell->name, "name is : " . $shell->name; Shell-Guess-0.08/t/shell_guess__tc.t0000644000175000017500000000212213216237257016737 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->tc_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 1, "c = 1"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 1, "tc = 1"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, '/bin/tcsh', 'default_location = /bin/tcsh'; Shell-Guess-0.08/t/shell_guess__os_proc.t0000644000175000017500000000175613216237257020011 0ustar ollisgollisguse strict; use warnings; use Test::More; use File::Spec; use lib 't/lib'; use FakeLogin; use Shell::Guess; my $sh = File::Spec->catdir('', 'bin', 'sh'); my $csh = File::Spec->catdir('', 'bin', 'csh'); plan skip_all => 'test requires a /proc filesystem' unless -f File::Spec->catdir('', 'proc', $$, 'cmdline'); plan skip_all => 'test requires bourne shell in /bin/sh' unless -x $sh; plan skip_all => 'test requires c shell in /bin/csh' unless -x $csh; plan skip_all => 'test requires that PERL5OPT not be set' if defined $ENV{PERL5OPT}; plan tests => 3; is(Shell::Guess->login_shell->is_bourne, 1, 'faked out a bourne shell'); $ENV{PERL5OPT} = "-It/lib -MFakeLogin"; like `$^X -MShell::Guess -e 'print Shell::Guess->login_shell->name, "\n"'`, qr{bourne}, 'sub process still found fake bourne shell'; my $lib = -d File::Spec->catdir('blib') ? '-Mblib' : "-I" . File::Spec->catdir('lib'); note "lib = $lib"; like `$csh -c '$^X $lib corpus/print_guess.pl'`, qr{c}, 'sub process found real c shell'; Shell-Guess-0.08/t/shell_guess__os_dos.t0000644000175000017500000000046513216237257017627 0ustar ollisgollisguse strict; use warnings; use Test::More; use Shell::Guess; plan skip_all => 'DOS only test' unless $^O eq 'dos'; plan tests => 2; is eval { Shell::Guess->running_shell->is_command }, 1, "running command"; diag $@ if $@; is eval { Shell::Guess->login_shell->is_command }, 1, "login command"; diag $@ if $@; Shell-Guess-0.08/t/shell_guess__bourne.t0000644000175000017500000000212213216237257017623 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->bourne_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 1, "bourne = 1"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, '/bin/sh', 'default_location = /bin/sh'; Shell-Guess-0.08/t/shell_guess__z.t0000644000175000017500000000211713216237257016606 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->z_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 1, "bourne = 1"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 1, "z = 1"; diag $@ if $@; is $shell->default_location, '/bin/zsh', 'default_location = /bin/zsh'; Shell-Guess-0.08/t/shell_guess__bash.t0000644000175000017500000000212413216237257017250 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->bash_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 1, "bash = 1"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 1, "bourne = 1"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, '/bin/bash', 'default_location = /bin/bash'; Shell-Guess-0.08/t/shell_guess__korn.t0000644000175000017500000000212213216237257017302 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->korn_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 1, "korn = 1"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 1, "bourne = 1"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, '/bin/ksh', 'default_location = /bin/ksh'; Shell-Guess-0.08/t/shell_guess__power.t0000644000175000017500000000201213216237257017463 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 15; use Shell::Guess; my $shell = eval { Shell::Guess->power_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 1, "win32 = 1"; diag $@ if $@; is eval { $shell->is_unix }, 0, "unix = 0"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 1, "power = 1"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; Shell-Guess-0.08/t/shell_guess__c.t0000644000175000017500000000211713216237257016557 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->c_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 1, "c = 1"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, '/bin/csh', 'default_location = /bin/csh'; Shell-Guess-0.08/t/shell_guess__dcl.t0000644000175000017500000000201013216237257017067 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 15; use Shell::Guess; my $shell = eval { Shell::Guess->dcl_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 1, "dcl = 1"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 0, "fish = 0"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 0, "unix = 0"; diag $@ if $@; is eval { $shell->is_vms }, 1, "vms = 1"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; Shell-Guess-0.08/t/00_diag.t0000644000175000017500000000234713216237257015011 0ustar ollisgollisguse strict; use warnings; use Config; use Test::More tests => 1; # This .t file is generated. # make changes instead to dist.ini my %modules; my $post_diag; $modules{$_} = $_ for qw( ExtUtils::MakeMaker Test::More Unix::Process Win32::Getppid Win32::Process::List ); my @modules = sort keys %modules; sub spacer () { diag ''; diag ''; diag ''; } pass 'okay'; my $max = 1; $max = $_ > $max ? $_ : $max for map { length $_ } @modules; our $format = "%-${max}s %s"; spacer; my @keys = sort grep /(MOJO|PERL|\A(LC|HARNESS)_|\A(SHELL|LANG)\Z)/i, keys %ENV; if(@keys > 0) { diag "$_=$ENV{$_}" for @keys; if($ENV{PERL5LIB}) { spacer; diag "PERL5LIB path"; diag $_ for split $Config{path_sep}, $ENV{PERL5LIB}; } elsif($ENV{PERLLIB}) { spacer; diag "PERLLIB path"; diag $_ for split $Config{path_sep}, $ENV{PERLLIB}; } spacer; } diag sprintf $format, 'perl ', $]; foreach my $module (@modules) { if(eval qq{ require $module; 1 }) { my $ver = eval qq{ \$$module\::VERSION }; $ver = 'undef' unless defined $ver; diag sprintf $format, $module, $ver; } else { diag sprintf $format, $module, '-'; } } if($post_diag) { spacer; $post_diag->(); } spacer; Shell-Guess-0.08/t/shell_guess__guess_running.t0000644000175000017500000000050113216237257021216 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 3; use Shell::Guess; my $shell = eval { Shell::Guess->running_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; ok $shell->is_win32 || $shell->is_unix || $shell->is_vms, 'shell is one of win32 unix or vms environment'; ok $shell->name, "name is : " . $shell->name;Shell-Guess-0.08/t/shell_guess__fish.t0000644000175000017500000000211213216237257017261 0ustar ollisgollisguse strict; use warnings; use Test::More tests => 16; use Shell::Guess; my $shell = eval { Shell::Guess->fish_shell }; diag $@ if $@; isa_ok $shell, 'Shell::Guess'; is eval { $shell->is_cmd }, 0, "cmd = 0"; diag $@ if $@; is eval { $shell->is_command }, 0, "command = 0"; diag $@ if $@; is eval { $shell->is_dcl }, 0, "dcl = 0"; diag $@ if $@; is eval { $shell->is_bash }, 0, "bash = 0"; diag $@ if $@; is eval { $shell->is_fish }, 1, "fish = 1"; diag $@ if $@; is eval { $shell->is_korn }, 0, "korn = 0"; diag $@ if $@; is eval { $shell->is_c }, 0, "c = 0"; diag $@ if $@; is eval { $shell->is_win32 }, 0, "win32 = 0"; diag $@ if $@; is eval { $shell->is_unix }, 1, "unix = 1"; diag $@ if $@; is eval { $shell->is_vms }, 0, "vms = 0"; diag $@ if $@; is eval { $shell->is_bourne }, 0, "bourne = 0"; diag $@ if $@; is eval { $shell->is_tc }, 0, "tc = 0"; diag $@ if $@; is eval { $shell->is_power }, 0, "power = 0"; diag $@ if $@; is eval { $shell->is_z }, 0, "z = 0"; diag $@ if $@; is $shell->default_location, undef, 'default_location = undef'; Shell-Guess-0.08/Changes0000644000175000017500000000230213216237257014440 0ustar ollisgollisgRevision history for Shell-Guess 0.08 2017-12-19 11:30:36 -0500 - Use /proc/[pid]/comm as a method for guessing the shell in addition to the methods already used (simbabque++) 0.07 2017-08-07 21:55:08 -0400 - Migrate back to MakeMaker from Module::Build (for got this time) 0.06 2015-01-21 09:36:40 -0500 - On Windows, use Win32::Getppid instead of Win32::Process::Info the latter was failing on Strawberry 64 and is overkill for the needs of this module. 0.05 2014-06-16 09:39:30 -0400 - fix for running_shell method on Solaris 0.04 2014-05-31 06:35:18 -0400 - avoid possible warnings on /proc read failure 0.03 2014-04-20 04:54:22 -0400 - promote to production 0.02_03 2014-04-19 08:06:27 -0400 - rm explicit dep on File::Spec due to typo 0.02_02 2014-04-19 08:03:51 -0400 - mark distribution as having dynamic_config as it ought to 0.02_01 2014-04-18 16:53:08 -0400 - only use argv[0] from command line for running_shell guess (thanks Buddy Burden GH#3) - migrate from MakeMaker to Module::Build 0.02 2014-01-06 20:54:01 -0500 - support for detecting Fish shell 0.01 2012-10-25 15:28:10 America/New_York - initial version Shell-Guess-0.08/INSTALL0000644000175000017500000000217213216237257014203 0ustar ollisgollisgThis is the Perl distribution Shell-Guess. Installing Shell-Guess is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm Shell::Guess If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan Shell::Guess ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib ## Documentation Shell-Guess documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc Shell::Guess