modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2023-11-04 00:59:42 +04:00
parent a1f88e9d38
commit af332ea961
1 changed files with 21 additions and 6 deletions

View File

@ -44,6 +44,9 @@ usage
USAGE USAGE
\$MYNAME [options] FILE \$MYNAME [options] FILE
~~~ ~~~
Peut contenir autant de lignes que nécessaire. Chaque ligne est préfixée du
nom du script, jusqu'à la première ligne vide. Ensuite, les lignes sont
affichées telles quelles.
+|- +|-
: méthode d'analyse des arguments. : méthode d'analyse des arguments.
@ -236,21 +239,33 @@ function __parse_args() {
help="$help: $__DESC" help="$help: $__DESC"
fi fi
local first usage nl=$'\n'
local prefix=" $MYNAME " local prefix=" $MYNAME "
local -a usages; local usage="$__USAGE" local usages="$__USAGE"
[ -n "$usage" ] || usage="[options]" [ -n "$usages" ] || usages="[options]"
IFS=$'\n' read -a usages -d "" <<<"$usage"
help="$help help="$help
USAGE" USAGE"
for usage in "${usages[@]}"; do first=1
[ -n "$usage" ] || continue while [ -n "$usages" ]; do
usage="${usages%%$nl*}"
if [ "$usage" != "$usages" ]; then
usages="${usages#*$nl}"
else
usages=
fi
if [ -n "$first" ]; then
first=
[ -z "$usage" ] && continue
else
[ -z "$usage" ] && prefix=
fi
help="$help help="$help
$prefix$usage" $prefix$usage"
done done
set -- "${__DEFS[@]}" set -- "${__DEFS[@]}"
local first=1 first=1
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
+) shift; continue;; +) shift; continue;;