1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 07:19:02 -08:00
rc/sh/clash
2024-07-28 15:58:41 -07:00

28 lines
773 B
Bash
Executable file

#!/usr/bin/env sh
# compat: +ash +bash +dash +zsh
clash() { ### @- run a command through 12 different shells.
### only returns false when no arguments are given.
[ $# != 0 ] || return
for sh in `__clash_shells`; do
printf >&2 '\033[7m %s \033[m\n' "trying $sh"
"$sh" "$@"
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 "$@"