Shell-Guess
view release on metacpan or search on metacpan
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";
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:
lib/Shell/Guess.pm view on Meta::CPAN
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";
lib/Shell/Guess.pm view on Meta::CPAN
a script that generates shell configurations for the calling shell so they
can be imported back into the calling shell using C<eval> and backticks
or C<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:
( run in 0.277 second using v1.01-cache-2.11-cpan-a1d94b6210f )