From 13c5e3ff21c58973ad234a96633e35b2530e002d Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 28 Jul 2024 15:50:12 -0700 Subject: [PATCH] update `clash` --- sh/clash | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sh/clash b/sh/clash index 46d50a0..8b919da 100755 --- a/sh/clash +++ b/sh/clash @@ -4,12 +4,25 @@ clash() { ### @- run a command through 12 different shells. ### only returns false when no arguments are given. [ $# != 0 ] || return - for sh in ash bash dash hush ksh loksh mksh oksh osh posh yash zsh; do + for sh in `__clash_shells`; do printf >&2 '\033[7m %s \033[m\n' "trying $sh" "$sh" "$@" - printf >&2 '\033[100m $?=%s \033[m\n' $? + eval "${sh}_x=$?" + done + if [ "$1" = -c ]; then + shift + printf >&2 '\033[7m\043\043\043\043 `%s`\033[m\n' "$*" + else + printf >&2 '\033[7m\043\043\043\043 sh %s\033[m\n' "$*" + fi + for sh in `__clash_shells`; do + printf >&2 '\033[100m#%5s: $? = %s\033[m\n' "$sh" "$((${sh}_x))" done true } +__clash_shells() { + echo ash bash dash hush ksh loksh mksh oksh osh posh yash zsh +} + [ -n "${preload+-}" ] || clash "$@"