2024-07-21 12:22:05 -07:00
|
|
|
#!/usr/bin/env false
|
|
|
|
# FAKE_COMPAT
|
|
|
|
|
|
|
|
cd ~/sh && unset IFS || exit
|
2024-07-21 13:45:16 -07:00
|
|
|
[ -z "${0##/*}" ] && sh=zsh || sh="${0#-}" # zsh replaces $0, so hardcode it
|
2024-07-21 13:05:32 -07:00
|
|
|
case "$sh" in
|
2024-07-21 12:22:05 -07:00
|
|
|
(ash) SH=ASH;;
|
|
|
|
(bash) SH=BASH;;
|
|
|
|
(dash) SH=DASH;;
|
|
|
|
(hush) SH=HUSH;;
|
|
|
|
(ksh) SH=KSH;;
|
2024-07-21 22:22:26 -07:00
|
|
|
(loksh) SH=MKSH;; # similar enough to mksh to use the same compatibility flag
|
2024-07-21 12:22:05 -07:00
|
|
|
(mksh) SH=MKSH;;
|
2024-07-21 22:22:26 -07:00
|
|
|
(oksh) SH=MKSH;; # similar enough to mksh to use the same compatibility flag
|
2024-07-21 12:22:05 -07:00
|
|
|
(osh) SH=OSH;;
|
|
|
|
(posh) SH=POSH;;
|
|
|
|
(yash) SH=YASH;;
|
2024-07-21 13:05:32 -07:00
|
|
|
(zsh) SH=ZSH; set -o SH_WORD_SPLIT;;
|
2024-07-21 12:22:05 -07:00
|
|
|
(*)
|
|
|
|
printf >&2 %s\\n "unknown shell (\$0): $0"
|
2024-07-21 13:05:32 -07:00
|
|
|
exit 1
|
2024-07-21 12:22:05 -07:00
|
|
|
esac
|
|
|
|
|
|
|
|
printf %s\\n '#!/usr/bin/env false' '[ -n "$preload" ] || exit 1' ''
|
2024-07-21 22:21:50 -07:00
|
|
|
for f in "${HOME:?}/sh"/*; do
|
2024-07-21 12:22:05 -07:00
|
|
|
[ -n "${f##*.*}" ] && [ -f "$f" ] || continue
|
|
|
|
i=10 sh=
|
|
|
|
while IFS= read -r line; do
|
|
|
|
for word in $line; do
|
|
|
|
case "$word" in (YES_$SH) sh=1;; (NO_$SH) sh=0;; esac
|
|
|
|
done
|
|
|
|
[ "$((i-=1))" != 0 ] || break # act like head -n10
|
|
|
|
done < "$f"
|
|
|
|
[ "$sh" != 1 ] || set -- "$@" "$f"
|
|
|
|
done
|
|
|
|
[ $# = 0 ] || cat "$@"
|