1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-14 08:59:03 -08:00
rc/sh/shelly

30 lines
846 B
Text
Raw Normal View History

#!/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) {
2022-08-29 22:05:38 -07:00
#print STDERR "path: $p\n";
my $fp = File::Spec->join($p, $s);
my @argv = $s eq "busybox" ? ("sh", "-i") : ($s, "-i");
2022-08-29 22:05:38 -07:00
if (-d "/C/") {
# probably Windows.
exec {"$fp.exe"} @argv if -f "$fp.exe" and -e "$fp.exe";
} else {
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";