mirror of
https://github.com/notwa/rc
synced 2024-11-05 07:19:02 -08:00
rewrite short-flag parsing in permit
This commit is contained in:
parent
e8623a568a
commit
8904f22242
1 changed files with 13 additions and 15 deletions
28
sh/permit
28
sh/permit
|
@ -53,22 +53,20 @@ permit() { ### @- conditionally set executable permissions on each of its argume
|
||||||
done
|
done
|
||||||
break;;
|
break;;
|
||||||
|
|
||||||
(-*)
|
(-?*)
|
||||||
shift
|
shift
|
||||||
case "${__permit_f#-}" in
|
while __permit_f="${__permit_f#?}"; [ -n "$__permit_f" ]; do
|
||||||
(a) __permit_a=1;; # automatic (on)
|
case "${__permit_f}" in
|
||||||
(A) __permit_a=0;; # automatic (off)
|
(a*) __permit_a=1;; # automatic (on)
|
||||||
(e) __permit_m=e;; # everything
|
(A*) __permit_a=0;; # automatic (off)
|
||||||
(f) __permit_m=f;; # files only
|
(e*) __permit_m=e;; # everything
|
||||||
(d) __permit_m=d;; # directories only
|
(f*) __permit_m=f;; # files only
|
||||||
(?|-*)
|
(d*) __permit_m=d;; # directories only
|
||||||
printf >&2 'permit: %s\n' "unknown flag: $__permit_f"
|
(*)
|
||||||
return 64;;
|
printf >&2 'permit: unknown flag: -%.1s\n' "$__permit_f"
|
||||||
(*)
|
return 64;;
|
||||||
set -- "${__permit_f%"${__permit_f#-?}"}" "-${__permit_f#-?}" "$@"
|
esac
|
||||||
: $((__permit_n+=2))
|
done;;
|
||||||
continue;;
|
|
||||||
esac;;
|
|
||||||
|
|
||||||
(*)
|
(*)
|
||||||
shift
|
shift
|
||||||
|
|
Loading…
Reference in a new issue