corriger le code de retour des fonctions e*
This commit is contained in:
		
							parent
							
								
									b6d53059a3
								
							
						
					
					
						commit
						4fef3da26f
					
				| @ -250,11 +250,12 @@ function show_debug() { [ -n "$NULIB_DEBUG" ]; } | ||||
| 
 | ||||
| function esection() { | ||||
| # Afficher une section. Toutes les indentations sont remises à zéro | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     NULIB__ESTACK= | ||||
|     __esection "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| 
 | ||||
| function etitle() { | ||||
| @ -290,45 +291,50 @@ function eend() { | ||||
| 
 | ||||
| function edesc() { | ||||
| # Afficher une description sous le titre courant | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __edesc "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| 
 | ||||
| function ebanner() { | ||||
| # Afficher un message très important encadré, puis attendre 5 secondes | ||||
|     show_error || return | ||||
|     show_error || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __ebanner "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     sleep 5 | ||||
|     return 0 | ||||
| } | ||||
| 
 | ||||
| function eimportant() { | ||||
| # Afficher un message très important | ||||
|     show_error || return | ||||
|     show_error || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __eimportant "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qimportant() { eimportant "$*"; quietc_echo "IMPORTANT: $*"; } | ||||
| 
 | ||||
| function eattention() { | ||||
| # Afficher un message important | ||||
|     show_warn || return | ||||
|     show_warn || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __eattention "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qattention() { eattention "$*"; quietc_echo "ATTENTION: $*"; } | ||||
| 
 | ||||
| function eerror() { | ||||
| # Afficher un message d'erreur | ||||
|     show_error || return | ||||
|     show_error || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __eerror "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qerror() { eerror "$*"; quietc_echo "ERROR: $*"; } | ||||
| 
 | ||||
| @ -420,45 +426,50 @@ function exit_with { | ||||
| 
 | ||||
| function ewarn() { | ||||
| # Afficher un message d'avertissement | ||||
|     show_warn || return | ||||
|     show_warn || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __ewarn "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qwarn() { ewarn "$*"; quietc_echo "WARN: $*"; } | ||||
| 
 | ||||
| function enote() { | ||||
| # Afficher un message d'information de même niveau qu'un avertissement | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __enote "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qnote() { enote "$*"; quietc_echo "NOTE: $*"; } | ||||
| 
 | ||||
| function einfo() { | ||||
| # Afficher un message d'information | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __einfo "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qinfo() { einfo "$*"; quietc_echo "INFO: $*"; } | ||||
| 
 | ||||
| function eecho() { | ||||
| # Afficher un message d'information sans préfixe | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __eecho "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| function qecho() { eecho "$*"; quietc_echo "$*"; } | ||||
| 
 | ||||
| function eecho_() { | ||||
|     show_info || return | ||||
|     show_info || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __eecho_ "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| 
 | ||||
| function trace() { | ||||
| @ -494,26 +505,27 @@ function trace_error() { | ||||
| 
 | ||||
| function edebug() { | ||||
| # Afficher un message de debug | ||||
|     show_debug || return | ||||
|     show_debug || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     __edebug "$*" 1>&2 | ||||
|     eval "$NULIB__ENABLE_SET_X" | ||||
|     return 0 | ||||
| } | ||||
| 
 | ||||
| # Afficher la description d'une opération. Cette fonction est particulièrement | ||||
| # appropriée dans le contexte d'un etitle. | ||||
| # Les variantes e (error), w (warning), n (note), i (info) permettent d'afficher | ||||
| # des couleurs différentes, mais toutes sont du niveau info. | ||||
| function estep() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estep "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepe() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepe "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepw() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepw "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepn() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepn "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepi() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepi "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estep_() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estep_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepe_() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepe_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepw_() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepw_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepn_() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepn_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estepi_() { show_info || return; eval "$NULIB__DISABLE_SET_X"; __estepi_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; } | ||||
| function estep() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estep "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepe() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepe "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepw() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepw "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepn() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepn "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepi() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepi "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estep_() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estep_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepe_() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepe_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepw_() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepw_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepn_() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepn_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| function estepi_() { show_info || return 0; eval "$NULIB__DISABLE_SET_X"; __estepi_ "$*" 1>&2; eval "$NULIB__ENABLE_SET_X"; return 0; } | ||||
| 
 | ||||
| function qstep() { estep "$*"; quietc_echo "* $*"; } | ||||
| 
 | ||||
| @ -557,7 +569,7 @@ function action() { | ||||
| 
 | ||||
| function asuccess() { | ||||
| # terminer l'action en cours avec le message de succès $* | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     [ -n "$*" ] || set -- "succès" | ||||
|     NULIB__INDENT=" " __asuccess "$*" 1>&2 | ||||
| @ -567,7 +579,7 @@ function asuccess() { | ||||
| } | ||||
| function afailure() { | ||||
| # terminer l'action en cours avec le message d'échec $* | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     [ -n "$*" ] || set -- "échec" | ||||
|     NULIB__INDENT=" " __afailure "$*" 1>&2 | ||||
| @ -578,7 +590,7 @@ function afailure() { | ||||
| function aresult() { | ||||
| # terminer l'action en cours avec un message de succès ou d'échec $2..* en | ||||
| # fonction du code de retour $1 (0=succès, sinon échec) | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     local r="${1:-0}"; shift | ||||
|     if [ "$r" == 0 ]; then | ||||
| @ -594,7 +606,7 @@ function aresult() { | ||||
| } | ||||
| function adone() { | ||||
| # terminer l'action en cours avec le message neutre $* | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return | ||||
|     [ "${NULIB__ESTACK%:a}" != "$NULIB__ESTACK" ] || return 0 | ||||
|     eval "$NULIB__DISABLE_SET_X" | ||||
|     [ -n "$*" ] && NULIB__INDENT=" " __adone "$*" 1>&2 | ||||
|     NULIB__ESTACK="${NULIB__ESTACK%:a}" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user