mirror of
https://github.com/notwa/rc
synced 2025-02-05 07:43:22 -08:00
implement new shell compatibility markers
This commit is contained in:
parent
0e37575acc
commit
74b2e5ef0a
1 changed files with 15 additions and 13 deletions
28
sh/recombine
28
sh/recombine
|
@ -4,18 +4,18 @@
|
||||||
cd ~/sh && unset IFS || exit
|
cd ~/sh && unset IFS || exit
|
||||||
[ -z "${0##/*}" ] && sh=zsh || sh="${0#-}" # zsh replaces $0, so hardcode it
|
[ -z "${0##/*}" ] && sh=zsh || sh="${0#-}" # zsh replaces $0, so hardcode it
|
||||||
case "$sh" in
|
case "$sh" in
|
||||||
(ash) SH=ASH;;
|
(ash) SH=ASH c=ash;;
|
||||||
(bash) SH=BASH;;
|
(bash) SH=BASH c=bash;;
|
||||||
(dash) SH=DASH;;
|
(dash) SH=DASH c=dash;;
|
||||||
(hush) SH=HUSH;;
|
(hush) SH=HUSH c=hush;;
|
||||||
(ksh) SH=KSH;;
|
(ksh) SH=KSH c=ksh;;
|
||||||
(loksh) SH=OKSH;; # similar enough to oksh to use the same compatibility flag
|
(loksh) SH=OKSH c=oksh;; # similar enough to oksh to use the same compatibility flag
|
||||||
(mksh) SH=MKSH;;
|
(mksh) SH=MKSH c=mksh;;
|
||||||
(oksh) SH=OKSH;;
|
(oksh) SH=OKSH c=oksh;;
|
||||||
(osh) SH=OSH;;
|
(osh) SH=OSH c=osh;;
|
||||||
(posh) SH=POSH;;
|
(posh) SH=POSH c=posh;;
|
||||||
(yash) SH=YASH;;
|
(yash) SH=YASH c=yash;;
|
||||||
(zsh) SH=ZSH; set -o SH_WORD_SPLIT;;
|
(zsh) SH=ZSH c=zsh; set -o SH_WORD_SPLIT;;
|
||||||
(*)
|
(*)
|
||||||
printf >&2 %s\\n "unknown shell (\$0): $0"
|
printf >&2 %s\\n "unknown shell (\$0): $0"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -26,8 +26,10 @@ for f in "${HOME:?}/sh"/*; do
|
||||||
[ -n "${f##*.*}" ] && [ -f "$f" ] || continue
|
[ -n "${f##*.*}" ] && [ -f "$f" ] || continue
|
||||||
i=10 sh=
|
i=10 sh=
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
check=0
|
||||||
for word in $line; do
|
for word in $line; do
|
||||||
case "$word" in (YES_$SH) sh=1;; (NO_$SH) sh=0;; esac
|
case "$word" in (YES_$SH) sh=1;; (NO_$SH) sh=0;; (compat:) check=1;; esac
|
||||||
|
[ "$check" != 1 ] || case "$word" in (+$c) sh=1;; (-$c) sh=0;; esac
|
||||||
done
|
done
|
||||||
[ "$((i-=1))" != 0 ] || break # act like head -n10
|
[ "$((i-=1))" != 0 ] || break # act like head -n10
|
||||||
done < "$f"
|
done < "$f"
|
||||||
|
|
Loading…
Add table
Reference in a new issue