mirror of
https://github.com/notwa/rc
synced 2024-11-05 08:19:03 -08:00
add shelly
as a weird hack for invoking interactive shells
This commit is contained in:
parent
a9f8dd642c
commit
a0c83289e3
1 changed files with 23 additions and 0 deletions
23
sh/shelly
Normal file
23
sh/shelly
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env perl
|
||||
### @ shelly
|
||||
### (perl 5) invoke the first shell found from a list of shells
|
||||
### as an interactive, non-login shell. arguments are ignored.
|
||||
|
||||
use strict;
|
||||
use Env qw(@PATH);
|
||||
use File::Spec;
|
||||
|
||||
# arbitrary ordering, feel free to change:
|
||||
my @shells = <zsh osh fish ion bash ash busybox ksh tcsh csh rc dash>;
|
||||
|
||||
for my $s (@shells) {
|
||||
for my $p (@PATH) {
|
||||
my $fp = File::Spec->join($p, $s);
|
||||
my @argv = $s eq "busybox" ? ("sh", "-i") : ($s, "-i");
|
||||
exec {$fp} @argv if -f $fp and -e "$fp";
|
||||
#print STDERR "fail: $fp\n";
|
||||
}
|
||||
}
|
||||
|
||||
print STDERR "$0: gave up; invoking `sh` without arguments...\n";
|
||||
exec {"sh"} "sh";
|
Loading…
Reference in a new issue