From a0c83289e35397701c59b496738dff4de50276f3 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 29 Oct 2021 15:58:23 +0200 Subject: [PATCH] add `shelly` as a weird hack for invoking interactive shells --- sh/shelly | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sh/shelly diff --git a/sh/shelly b/sh/shelly new file mode 100644 index 0000000..610cc28 --- /dev/null +++ b/sh/shelly @@ -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 = ; + +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";