# # spec file for package perl-Shell-Config-Generate # # Copyright (c) 2018 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 https://bugs.opensuse.org/ # Name: perl-Shell-Config-Generate Version: 0.33 Release: 0 %define cpan_name Shell-Config-Generate Summary: Portably generate config for any shell License: Artistic-1.0 OR GPL-1.0-or-later Group: Development/Libraries/Perl Url: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Shell::Guess) >= 0.02 BuildRequires: perl(Test2::API) >= 1.302015 BuildRequires: perl(Test2::Mock) >= 0.000060 BuildRequires: perl(Test2::V0) >= 0.000060 Requires: perl(Shell::Guess) >= 0.02 %{perl_requires} %description This module provides an interface for specifying shell configurations for different shell environments without having to worry about the arcane differences between shells such as csh, sh, cmd.exe and command.com. It does not modify the current environment, but it can be used to create shell configurations which do modify the environment. This module uses Shell::Guess to represent the different types of shells that are supported. In this way you can statically specify just one or more shells: #!/usr/bin/perl use Shell::Guess; use Shell::Config::Generate; my $config = Shell::Config::Generate->new; # ... config config ... $config->generate_file(Shell::Guess->bourne_shell, 'foo.sh' ); $config->generate_file(Shell::Guess->c_shell, 'foo.csh'); $config->generate_file(Shell::Guess->cmd_shell, 'foo.cmd'); $config->generate_file(Shell::Guess->command_shell, 'foo.bat'); This will create foo.sh and foo.csh versions of the configurations, which can be sourced like so: #!/bin/sh . ./foo.sh or #!/bin/csh source foo.csh It also creates '.cmd' and '.bat' files with the same configuration which can be used in Windows. The configuration can be imported back into your shell by simply executing these files: C:\> foo.cmd or C:\> foo.bat Alternatively you can use the shell that called your Perl script using Shell::Guess's 'running_shell' method, and write the output to standard out. #!/usr/bin/perl use Shell::Guess; use Shell::Config::Generate; my $config = Shell::Config::Generate->new; # ... config config ... print $config->generate(Shell::Guess->running_shell); If you use this pattern, you can eval the output of your script using your shell's back ticks to import the configuration into the shell. #!/bin/sh eval `script.pl` or #!/bin/csh eval `script.pl` %prep %setup -q -n %{cpan_name}-%{version} find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644 %build perl Makefile.PL INSTALLDIRS=vendor make %{?_smp_mflags} %check make test %install %perl_make_install %perl_process_packlist %perl_gen_filelist %files -f %{name}.files %defattr(-,root,root,755) %doc author.yml Changes corpus example maint README %license LICENSE %changelog