Shell-Guess-0.10/000755 000000 000000 00000000000 14723751573 013561 5ustar00rootroot000000 000000 Shell-Guess-0.10/Changes000644 000000 000000 00000002611 14723751573 015054 0ustar00rootroot000000 000000 Revision history for Shell-Guess 0.10 2024-12-03 20:58:50 -0700 - Supress warning in Makefile.PL about calling getppid in void context (gh#12, gh#13) 0.09 2018-12-06 21:07:21 -0500 - Detect PowerShell on Unix (pwsh) 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.10/INSTALL000644 000000 000000 00000004544 14723751573 014621 0ustar00rootroot000000 000000 This 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. If you have not already downloaded the release tarball, you can find the download link on the module's MetaCPAN page: https://metacpan.org/pod/Shell::Guess Untar the tarball, install configure prerequisites (see below), then build it: % perl Makefile.PL % make && make test Then install it: % make install On Windows platforms, you should use `dmake` or `nmake`, instead of `make`. 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 The prerequisites of this distribution will also have to be installed manually. The prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated by running the manual build process described above. ## Configure Prerequisites This distribution requires other modules to be installed before this distribution's installer can be run. They can be found under the "configure_requires" key of META.yml or the "{prereqs}{configure}{requires}" key of META.json. ## Other Prerequisites This distribution may require additional modules to be installed after running Makefile.PL. Look for prerequisites in the following phases: * to run make, PHASE = build * to use the module code itself, PHASE = runtime * to run tests, PHASE = test They can all be found in the "PHASE_requires" key of MYMETA.yml or the "{prereqs}{PHASE}{requires}" key of MYMETA.json. ## Documentation Shell-Guess documentation is available as POD. You can run `perldoc` from a shell to read the documentation: % perldoc Shell::Guess For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html Shell-Guess-0.10/LICENSE000644 000000 000000 00000046446 14723751573 014604 0ustar00rootroot000000 000000 This software is copyright (c) 2012-2023 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-2023 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 Perl Artistic License 1.0 --- This software is Copyright (c) 2012-2023 by Graham Ollis. This is free software, licensed under: The Perl 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 as specified below. "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 uunet.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) give non-standard executables non-standard names, and clearly document 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. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 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 whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Shell-Guess-0.10/MANIFEST000644 000000 000000 00000001535 14723751573 014716 0ustar00rootroot000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. 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.10/META.json000644 000000 000000 00000004644 14723751573 015212 0ustar00rootroot000000 000000 { "abstract" : "Make an educated guess about the shell in use", "author" : [ "Graham Ollis " ], "dynamic_config" : 1, "generated_by" : "Dist::Zilla version 6.032, 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" : { "recommends" : { "Dist::Zilla::Plugin::Author::Plicease::Thanks" : "0", "Dist::Zilla::Plugin::Author::Plicease::Upload" : "0", "Dist::Zilla::Plugin::DynamicPrereqs" : "0", "Dist::Zilla::Plugin::Meta::Dynamic::Config" : "0", "Dist::Zilla::Plugin::RemovePrereqs" : "0", "Dist::Zilla::PluginBundle::Author::Plicease" : "2.69", "Software::License::Perl_5" : "0" }, "requires" : { "Test::CPAN::Changes" : "0", "Test::EOL" : "0", "Test::Fixme" : "0.07", "Test::More" : "0.98", "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.98", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/uperl/Shell-Guess/issues" }, "homepage" : "https://metacpan.org/pod/Shell::Guess", "repository" : { "type" : "git", "url" : "git://github.com/uperl/Shell-Guess.git", "web" : "https://github.com/uperl/Shell-Guess" } }, "version" : "0.10", "x_contributors" : [ "Graham Ollis ", "Buddy Burden (BAREFOOT)", "Julien Fiegehenn (SIMBABQUE)" ], "x_generated_by_perl" : "v5.40.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.38", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_use_unsafe_inc" : 0 } Shell-Guess-0.10/META.yml000644 000000 000000 00000001655 14723751573 015041 0ustar00rootroot000000 000000 --- abstract: 'Make an educated guess about the shell in use' author: - 'Graham Ollis ' build_requires: Test::More: '0.98' perl: '5.006' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.006' dynamic_config: 1 generated_by: 'Dist::Zilla version 6.032, 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/uperl/Shell-Guess/issues homepage: https://metacpan.org/pod/Shell::Guess repository: git://github.com/uperl/Shell-Guess.git version: '0.10' x_contributors: - 'Graham Ollis ' - 'Buddy Burden (BAREFOOT)' - 'Julien Fiegehenn (SIMBABQUE)' x_generated_by_perl: v5.40.0 x_serialization_backend: 'YAML::Tiny version 1.74' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_use_unsafe_inc: 0 Shell-Guess-0.10/Makefile.PL000644 000000 000000 00000005203 14723751573 015533 0ustar00rootroot000000 000000 BEGIN { use strict; use warnings; 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.75. 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.98" }, "VERSION" => "0.10", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Test::More" => "0.98" ); # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.040 if ( ( $^O ne 'dos' && $^O ne 'VMS' && $^O ne 'MSWin32' && eval { my $ppid = getppid; 1 } ) && !do { require File::Spec; -e File::Spec->catfile( '', 'proc', getppid, 'cmdline' ) } ) { requires('Unix::Process'); } # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.040 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.040 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 $FallbackPrereqs{$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.10/README000644 000000 000000 00000026574 14723751573 014457 0ustar00rootroot000000 000000 NAME Shell::Guess - Make an educated guess about the shell in use VERSION version 0.10 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 Microsoft PowerShell (either for Windows powershell.exe or Unix pwsh). 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, powershell.exe, pwsh) 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-2023 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.10/author.yml000644 000000 000000 00000000517 14723751573 015611 0ustar00rootroot000000 000000 --- pod_spelling_system: stopwords: - login - OpenVMS - bourne - UNIXy - dcl - korn - cmd.exe - command.com - ComSpec - cmd - tc - PowerShell - powershell - pwsh - prereqs - FreeBSD - ps - dscl - proc - exe - Fiegehenn - Julien - SIMBABQUE Shell-Guess-0.10/corpus/000755 000000 000000 00000000000 14723751573 015074 5ustar00rootroot000000 000000 Shell-Guess-0.10/corpus/print_guess.pl000644 000000 000000 00000000134 14723751573 017771 0ustar00rootroot000000 000000 use strict; use warnings; use Shell::Guess; print Shell::Guess->running_shell->name, "\n"; Shell-Guess-0.10/dist.ini000644 000000 000000 00000002432 14723751573 015226 0ustar00rootroot000000 000000 name = Shell-Guess author = Graham Ollis license = Perl_5 copyright_holder = Graham Ollis copyright_year = 2012-2023 version = 0.10 [@Author::Plicease] :version = 2.69 release_tests = 1 diag = +Unix::Process diag = +Win32::Getppid diag = +Win32::Process::List github_user = uperl workflow = static workflow = linux workflow = windows workflow = macos [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 { my $ppid = 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.10/lib/000755 000000 000000 00000000000 14723751573 014327 5ustar00rootroot000000 000000 Shell-Guess-0.10/lib/Shell/000755 000000 000000 00000000000 14723751573 015376 5ustar00rootroot000000 000000 Shell-Guess-0.10/lib/Shell/Guess.pm000644 000000 000000 00000040423 14723751573 017025 0ustar00rootroot000000 000000 package 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.10'; # 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}; unless(defined $username) { $username = eval { getpwuid $< }; } 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 =~ /pwsh$/) { return __PACKAGE__->power_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.10 =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 Microsoft PowerShell (either for Windows C or Unix C). 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, powershell.exe, pwsh) =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-2023 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.10/t/000755 000000 000000 00000000000 14723751573 014024 5ustar00rootroot000000 000000 Shell-Guess-0.10/t/00_diag.t000644 000000 000000 00000002427 14723751573 015421 0ustar00rootroot000000 000000 use 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', "$] $^O $Config{archname}"; foreach my $module (@modules) { my $pm = "$module.pm"; $pm =~ s{::}{/}g; if(eval { require $pm; 1 }) { my $ver = eval { $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.10/t/lib/000755 000000 000000 00000000000 14723751573 014572 5ustar00rootroot000000 000000 Shell-Guess-0.10/t/lib/FakeLogin.pm000644 000000 000000 00000000273 14723751573 016771 0ustar00rootroot000000 000000 package 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.10/t/shell_guess__bash.t000644 000000 000000 00000002124 14723751573 017661 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__bourne.t000644 000000 000000 00000002122 14723751573 020234 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__c.t000644 000000 000000 00000002117 14723751573 017170 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__cmd.t000644 000000 000000 00000002175 14723751573 017515 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__command.t000644 000000 000000 00000002211 14723751573 020357 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__dcl.t000644 000000 000000 00000002010 14723751573 017500 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__fish.t000644 000000 000000 00000002112 14723751573 017672 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__guess_login.t000644 000000 000000 00000000500 14723751573 021256 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__guess_running.t000644 000000 000000 00000000501 14723751573 021627 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__korn.t000644 000000 000000 00000002122 14723751573 017713 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__os_dos.t000644 000000 000000 00000000465 14723751573 020240 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__os_proc.t000644 000000 000000 00000001756 14723751573 020422 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__os_vms.t000644 000000 000000 00000000444 14723751573 020255 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__os_win32.t000644 000000 000000 00000001605 14723751573 020412 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__power.t000644 000000 000000 00000002012 14723751573 020074 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__tc.t000644 000000 000000 00000002122 14723751573 017350 0ustar00rootroot000000 000000 use 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.10/t/shell_guess__z.t000644 000000 000000 00000002117 14723751573 017217 0ustar00rootroot000000 000000 use 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.10/xt/000755 000000 000000 00000000000 14723751573 014214 5ustar00rootroot000000 000000 Shell-Guess-0.10/xt/author/000755 000000 000000 00000000000 14723751573 015516 5ustar00rootroot000000 000000 Shell-Guess-0.10/xt/author/eol.t000644 000000 000000 00000000510 14723751573 016456 0ustar00rootroot000000 000000 use 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.10/xt/author/no_tabs.t000644 000000 000000 00000000522 14723751573 017327 0ustar00rootroot000000 000000 use 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.10/xt/author/pod.t000644 000000 000000 00000000472 14723751573 016470 0ustar00rootroot000000 000000 use 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.10/xt/author/pod_coverage.t000644 000000 000000 00000004001 14723751573 020333 0ustar00rootroot000000 000000 use 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; }; plan skip_all => 'test does not always work in cip check' if defined $ENV{CIPSTATIC} && $ENV{CIPSTATIC} eq 'true'; }; 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.10/xt/author/pod_spelling_common.t000644 000000 000000 00000001350 14723751573 021731 0ustar00rootroot000000 000000 use 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.10/xt/author/pod_spelling_system.t000644 000000 000000 00000002367 14723751573 021776 0ustar00rootroot000000 000000 use 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.10/xt/author/strict.t000644 000000 000000 00000001031 14723751573 017206 0ustar00rootroot000000 000000 use 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.10/xt/author/version.t000644 000000 000000 00000001473 14723751573 017375 0ustar00rootroot000000 000000 use 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 YAML' unless eval q{ use YAML; 1; }; } 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; if($config->{version}->{dir}) { note "using dir " . $config->{version}->{dir} } version_all_ok($config->{version}->{dir} ? ($config->{version}->{dir}) : ()); done_testing; Shell-Guess-0.10/xt/release/000755 000000 000000 00000000000 14723751573 015634 5ustar00rootroot000000 000000 Shell-Guess-0.10/xt/release/changes.t000644 000000 000000 00000001113 14723751573 017425 0ustar00rootroot000000 000000 use 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.10/xt/release/fixme.t000644 000000 000000 00000000616 14723751573 017134 0ustar00rootroot000000 000000 use 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, );