foreach: améliorer l'affichage

This commit is contained in:
Jephté Clain 2016-06-08 12:34:22 +04:00
parent c669e8fa57
commit 1eba9a75af
1 changed files with 11 additions and 1 deletions

12
foreach
View File

@ -30,12 +30,17 @@ OPTIONS
-a, --all
Faire la correspondance de l'expression sur les répertoires
-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=
match=all
changedir=
title=1
args=(+
--help '$exit_with display_help'
-b:,--basedir: basedir=
@ -44,6 +49,8 @@ args=(+
-f,-file match=file
-a,--all match=all
-s,--string match=string
-t,--title title=1
--no-title title=
)
parse_args "$@"; set -- "${args[@]}"
@ -64,11 +71,14 @@ case "$match" in
string) eval "items=($expr)";;
esac
[ -n "$title" ] && einfo "${#items[@]} correspondance(s) trouvée(s)"
let index=0
for item in "${items[@]}"; do
[ -n "$title" ] && etitle "$item"
(
[ -n "$changedir" ] && cd "$item"
eval "export $(echo_setv "$varname" "$item"); ${cmd[*]}"
)
[ -n "$title" ] && eend "$item"
let index=$index+1
done