1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-04-24 17:03:22 -07:00

Compare commits

...

4 Commits

6 changed files with 39 additions and 3 deletions

View File

@ -645,6 +645,11 @@ as a simple example, `echo hey | shcom` produces, verbatim:
hey
```
### [shelly](/sh/shelly#L2)
(perl 5) invoke the first shell found from a list of shells
as an interactive, non-login shell. arguments are ignored.
### [similar](/sh/similar#L8)
highlight adjacent lines up to the first inequivalent character.
@ -1172,6 +1177,7 @@ print each argument on its own line.
| [scramble](#scramble) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [scropt](#scropt) | bash | ✔️ | ✔️ | ✔️ | ✔️ |
| [shcom](#shcom) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [shelly](#shelly) | **perl** | *n/a* | *n/a* | *n/a* | *n/a* |
| [similar](#similar) | *sh* | ✔️ | ✔️ | ✔️ | ✔️ |
| [slit](#slit) | dash | ✔️ | ✔️ | ✔️ | ✔️ |
| [slitt](#slitt) | dash | ✔️ | ✔️ | ✔️ | ✔️ |

0
sh/colors2 Normal file → Executable file
View File

0
sh/dated Normal file → Executable file
View File

0
sh/have Normal file → Executable file
View File

23
sh/shelly Executable file
View 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";

View File

@ -55,6 +55,7 @@ tableize() {
'!/usr/bin/env bash') pref=bash;;
'!/usr/bin/env dash') pref=dash;;
'!/usr/bin/env false') pref=false;;
'!/usr/bin/env perl') pref=perl;;
'!/usr/bin/env sh') pref=sh;;
'!/usr/bin/env zsh') pref=zsh;;
'!/usr/bin/sh') pref=sh;;
@ -72,16 +73,22 @@ tableize() {
local yay='✔️' # yay='y'
local nay='⭕' # nay='✖️' # nay='n'
local huh='❔' # huh='?'
local etc='*n/a*'
# TODO: escape underscores in filenames.
printf '| [%s](#%s) ' "$fn" "$fn"
printf "%$(( 40 - 2 * ${#fn} ))s" '' # funky way to pad the rest of the column
[ "$pref" != false ] || pref='**false**'
[ "$pref" != sh ] || pref='*sh*'
[ -n "$pref" ] && printf '| %10s ' "$pref" || printf '| %9s%s ' '' "$huh"
local p="$pref"
[ "$pref" != false ] || p='**false**'
[ "$pref" != perl ] || p='**perl**'
[ "$pref" != sh ] || p='*sh*'
[ -n "$p" ] && printf '| %10s ' "$p" || printf '| %9s%s ' '' "$huh"
local t=
for t in "$zsh" "$bash" "$dash" "$ash"; do
local w="$huh"
[ "$pref" != perl ] || w="$etc"
[ "$t" != yes ] || w="$yay"
[ "$t" != no ] || w="$nay"
# can't use '%4s' here because printf gets confused by UTF-8.