2024-07-01 22:11:33 -07:00
|
|
|
#!/usr/bin/env sh
|
2024-07-22 05:28:58 -07:00
|
|
|
# compat: +ash +bash +dash +zsh
|
2024-07-01 22:11:33 -07:00
|
|
|
|
2024-07-21 22:32:56 -07:00
|
|
|
clash() { ### @- run a command through 12 different shells.
|
2024-07-01 22:11:33 -07:00
|
|
|
### only returns false when no arguments are given.
|
|
|
|
[ $# != 0 ] || return
|
2024-07-28 15:50:12 -07:00
|
|
|
for sh in `__clash_shells`; do
|
2024-07-21 22:32:56 -07:00
|
|
|
printf >&2 '\033[7m %s \033[m\n' "trying $sh"
|
2024-07-01 22:11:33 -07:00
|
|
|
"$sh" "$@"
|
2024-07-28 15:50:12 -07:00
|
|
|
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))"
|
2024-07-01 22:11:33 -07:00
|
|
|
done
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2024-07-28 15:50:12 -07:00
|
|
|
__clash_shells() {
|
|
|
|
echo ash bash dash hush ksh loksh mksh oksh osh posh yash zsh
|
|
|
|
}
|
|
|
|
|
2024-07-01 22:11:33 -07:00
|
|
|
[ -n "${preload+-}" ] || clash "$@"
|