foreach: améliorer l'affichage
This commit is contained in:
parent
c669e8fa57
commit
1eba9a75af
12
foreach
12
foreach
|
@ -30,12 +30,17 @@ OPTIONS
|
||||||
-a, --all
|
-a, --all
|
||||||
Faire la correspondance de l'expression sur les répertoires
|
Faire la correspondance de l'expression sur les répertoires
|
||||||
-s, --string
|
-s, --string
|
||||||
Evaluer la chaine avec le shell"
|
Evaluer la chaine avec le shell
|
||||||
|
-t, --title
|
||||||
|
--no-title
|
||||||
|
Afficher (resp. ne pas afficher) chaque correspondance avant de lancer
|
||||||
|
la commande. Par défaut, l'affichage est effectué."
|
||||||
}
|
}
|
||||||
|
|
||||||
basedir=
|
basedir=
|
||||||
match=all
|
match=all
|
||||||
changedir=
|
changedir=
|
||||||
|
title=1
|
||||||
args=(+
|
args=(+
|
||||||
--help '$exit_with display_help'
|
--help '$exit_with display_help'
|
||||||
-b:,--basedir: basedir=
|
-b:,--basedir: basedir=
|
||||||
|
@ -44,6 +49,8 @@ args=(+
|
||||||
-f,-file match=file
|
-f,-file match=file
|
||||||
-a,--all match=all
|
-a,--all match=all
|
||||||
-s,--string match=string
|
-s,--string match=string
|
||||||
|
-t,--title title=1
|
||||||
|
--no-title title=
|
||||||
)
|
)
|
||||||
parse_args "$@"; set -- "${args[@]}"
|
parse_args "$@"; set -- "${args[@]}"
|
||||||
|
|
||||||
|
@ -64,11 +71,14 @@ case "$match" in
|
||||||
string) eval "items=($expr)";;
|
string) eval "items=($expr)";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
[ -n "$title" ] && einfo "${#items[@]} correspondance(s) trouvée(s)"
|
||||||
let index=0
|
let index=0
|
||||||
for item in "${items[@]}"; do
|
for item in "${items[@]}"; do
|
||||||
|
[ -n "$title" ] && etitle "$item"
|
||||||
(
|
(
|
||||||
[ -n "$changedir" ] && cd "$item"
|
[ -n "$changedir" ] && cd "$item"
|
||||||
eval "export $(echo_setv "$varname" "$item"); ${cmd[*]}"
|
eval "export $(echo_setv "$varname" "$item"); ${cmd[*]}"
|
||||||
)
|
)
|
||||||
|
[ -n "$title" ] && eend "$item"
|
||||||
let index=$index+1
|
let index=$index+1
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue