131 lines
4.1 KiB
RPMSpec
131 lines
4.1 KiB
RPMSpec
![]() |
#
|
||
|
# spec file for package perl-Shell-Guess
|
||
|
#
|
||
|
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||
|
#
|
||
|
# All modifications and additions to the file contributed by third parties
|
||
|
# remain the property of their copyright owners, unless otherwise agreed
|
||
|
# upon. The license for this file, and modifications and additions to the
|
||
|
# file, is the same license as for the pristine package itself (unless the
|
||
|
# license for the pristine package is not an Open Source License, in which
|
||
|
# case the license is the MIT License). An "Open Source License" is a
|
||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||
|
# published by the Open Source Initiative.
|
||
|
|
||
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||
|
#
|
||
|
|
||
|
|
||
|
Name: perl-Shell-Guess
|
||
|
Version: 0.06
|
||
|
Release: 0
|
||
|
%define cpan_name Shell-Guess
|
||
|
Summary: Make an educated guess about the shell in use
|
||
|
License: Artistic-1.0 or GPL-1.0+
|
||
|
Group: Development/Libraries/Perl
|
||
|
Url: http://search.cpan.org/dist/Shell-Guess/
|
||
|
Source: http://www.cpan.org/authors/id/P/PL/PLICEASE/%{cpan_name}-%{version}.tar.gz
|
||
|
BuildArch: noarch
|
||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||
|
BuildRequires: perl
|
||
|
BuildRequires: perl-macros
|
||
|
BuildRequires: perl(Module::Build) >= 0.28
|
||
|
BuildRequires: perl(Test::More) >= 0.94
|
||
|
%{perl_requires}
|
||
|
|
||
|
%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.
|
||
|
|
||
|
* * the Win32::Getppid manpage and the Win32::Process::List manpage
|
||
|
|
||
|
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
|
||
|
|
||
|
the Shell::Config::Generate manpage provides a portable interface for
|
||
|
generating such shell configurations, and is designed to work with this
|
||
|
module.
|
||
|
|
||
|
%prep
|
||
|
%setup -q -n %{cpan_name}-%{version}
|
||
|
|
||
|
%build
|
||
|
%{__perl} Build.PL installdirs=vendor
|
||
|
./Build build flags=%{?_smp_mflags}
|
||
|
|
||
|
%check
|
||
|
./Build test
|
||
|
|
||
|
%install
|
||
|
./Build install destdir=%{buildroot} create_packlist=0
|
||
|
%perl_gen_filelist
|
||
|
|
||
|
%files -f %{name}.files
|
||
|
%defattr(-,root,root,755)
|
||
|
%doc Changes LICENSE README
|
||
|
|
||
|
%changelog
|