maj bash
This commit is contained in:
parent
5f15e1ea8c
commit
2e8d0ac010
2
.udir
2
.udir
|
@ -9,7 +9,7 @@ uinc_options=()
|
||||||
uinc_args=()
|
uinc_args=()
|
||||||
preconfig_scripts=()
|
preconfig_scripts=()
|
||||||
configure_variables=(dest)
|
configure_variables=(dest)
|
||||||
configure_dest_for=(lib/profile.d/nucore)
|
configure_dest_for=(lib/profile.d/nulib)
|
||||||
config_scripts=(lib/uinst/conf)
|
config_scripts=(lib/uinst/conf)
|
||||||
install_profiles=true
|
install_profiles=true
|
||||||
profiledir=lib/profile.d
|
profiledir=lib/profile.d
|
||||||
|
|
|
@ -7,9 +7,9 @@ function: local_args "Afficher des commandes pour rendre locales des variables u
|
||||||
Cela permet d'utiliser parse_args() à l'intérieur d'une fonction."
|
Cela permet d'utiliser parse_args() à l'intérieur d'une fonction."
|
||||||
function local_args() {
|
function local_args() {
|
||||||
echo "local args"
|
echo "local args"
|
||||||
echo "local NUCORE_ARGS_ONERROR_RETURN=1"
|
echo "local NULIB_ARGS_ONERROR_RETURN=1"
|
||||||
echo "local NUCORE_VERBOSITY=\"\$NUCORE_VERBOSITY\""
|
echo "local NULIB_VERBOSITY=\"\$NULIB_VERBOSITY\""
|
||||||
echo "local NUCORE_INTERACTION=\"\$NUCORE_INTERACTION\""
|
echo "local NULIB_INTERACTION=\"\$NULIB_INTERACTION\""
|
||||||
}
|
}
|
||||||
|
|
||||||
function: parse_args "Analyser les arguments de la ligne de commande à partir des définitions du tableau args
|
function: parse_args "Analyser les arguments de la ligne de commande à partir des définitions du tableau args
|
||||||
|
@ -98,9 +98,9 @@ action
|
||||||
optdesc
|
optdesc
|
||||||
: description de l'option. cette valeur est facultative"
|
: description de l'option. cette valeur est facultative"
|
||||||
function parse_args() {
|
function parse_args() {
|
||||||
[ -z "$NUCORE_NO_DISABLE_SET_X" ] && [[ $- == *x* ]] && { set +x; local NUCORE_ARGS_SET_X=1; }
|
[ -z "$NULIB_NO_DISABLE_SET_X" ] && [[ $- == *x* ]] && { set +x; local NULIB_ARGS_SET_X=1; }
|
||||||
local __r=
|
local __r=
|
||||||
local __DIE='[ -n "$NUCORE_ARGS_ONERROR_RETURN" ] && return 1 || die'
|
local __DIE='[ -n "$NULIB_ARGS_ONERROR_RETURN" ] && return 1 || die'
|
||||||
|
|
||||||
if ! is_array args; then
|
if ! is_array args; then
|
||||||
eerror "Invalid args definition: args must be defined"
|
eerror "Invalid args definition: args must be defined"
|
||||||
|
@ -122,7 +122,7 @@ function parse_args() {
|
||||||
__DEFS=("$@")
|
__DEFS=("$@")
|
||||||
__parse_args || __r=1
|
__parse_args || __r=1
|
||||||
fi
|
fi
|
||||||
[ -n "$NUCORE_ARGS_SET_X" ] && set -x
|
[ -n "$NULIB_ARGS_SET_X" ] && set -x
|
||||||
if [ -n "$__r" ]; then
|
if [ -n "$__r" ]; then
|
||||||
eval "$__DIE"
|
eval "$__DIE"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -413,12 +413,12 @@ function upvars() {
|
||||||
|
|
||||||
function: set_debug "Passer en mode DEBUG"
|
function: set_debug "Passer en mode DEBUG"
|
||||||
function set_debug() {
|
function set_debug() {
|
||||||
export NUCORE_DEBUG=1
|
export NULIB_DEBUG=1
|
||||||
}
|
}
|
||||||
|
|
||||||
function: is_debug "Tester si on est en mode DEBUG"
|
function: is_debug "Tester si on est en mode DEBUG"
|
||||||
function is_debug() {
|
function is_debug() {
|
||||||
[ -n "$NUCORE_DEBUG" ]
|
[ -n "$NULIB_DEBUG" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
function: lawk "Lancer GNUawk avec la librairie 'base'"
|
function: lawk "Lancer GNUawk avec la librairie 'base'"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
module: base.init "Fonctions de base: initialiser l'environnement"
|
module: base.init "Fonctions de base: initialiser l'environnement"
|
||||||
|
|
||||||
if [ -z "$NUCORE_NO_INIT_ENV" ]; then
|
if [ -z "$NULIB_NO_INIT_ENV" ]; then
|
||||||
# Emplacement du script courant
|
# Emplacement du script courant
|
||||||
if [ "$0" == "-bash" ]; then
|
if [ "$0" == "-bash" ]; then
|
||||||
MYNAME=
|
MYNAME=
|
||||||
|
@ -19,7 +19,7 @@ if [ -z "$NUCORE_NO_INIT_ENV" ]; then
|
||||||
MYDIR="$(cd "$MYDIR"; pwd)"
|
MYDIR="$(cd "$MYDIR"; pwd)"
|
||||||
MYSELF="$MYDIR/$MYNAME"
|
MYSELF="$MYDIR/$MYNAME"
|
||||||
fi
|
fi
|
||||||
[ -n "$NUCOREDIR" ] || NUCOREDIR="$MYDIR"
|
[ -n "$NULIBDIR" ] || NULIBDIR="$MYDIR"
|
||||||
|
|
||||||
# Repertoire temporaire
|
# Repertoire temporaire
|
||||||
[ -z "$TMPDIR" -a -d "$HOME/tmp" ] && TMPDIR="$HOME/tmp"
|
[ -z "$TMPDIR" -a -d "$HOME/tmp" ] && TMPDIR="$HOME/tmp"
|
||||||
|
@ -29,20 +29,20 @@ if [ -z "$NUCORE_NO_INIT_ENV" ]; then
|
||||||
# User
|
# User
|
||||||
[ -z "$USER" -a -n "$LOGNAME" ] && export USER="$LOGNAME"
|
[ -z "$USER" -a -n "$LOGNAME" ] && export USER="$LOGNAME"
|
||||||
|
|
||||||
# Le fichier nucorerc doit être chargé systématiquement
|
# Le fichier nulibrc doit être chargé systématiquement
|
||||||
[ -f /etc/debian_chroot ] && NUCORE_CHROOT=1
|
[ -f /etc/debian_chroot ] && NULIB_CHROOT=1
|
||||||
[ -f /etc/nucorerc ] && . /etc/nucorerc
|
[ -f /etc/nulibrc ] && . /etc/nulibrc
|
||||||
[ -f ~/.nucorerc ] && . ~/.nucorerc
|
[ -f ~/.nulibrc ] && . ~/.nulibrc
|
||||||
|
|
||||||
# Type de système sur lequel tourne le script
|
# Type de système sur lequel tourne le script
|
||||||
UNAME_SYSTEM=`uname -s`
|
UNAME_SYSTEM=`uname -s`
|
||||||
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
|
[ "${UNAME_SYSTEM#CYGWIN}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Cygwin
|
||||||
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
|
[ "${UNAME_SYSTEM#MINGW32}" != "$UNAME_SYSTEM" ] && UNAME_SYSTEM=Mingw
|
||||||
UNAME_MACHINE=`uname -m`
|
UNAME_MACHINE=`uname -m`
|
||||||
if [ -n "$NUCORE_CHROOT" ]; then
|
if [ -n "$NULIB_CHROOT" ]; then
|
||||||
# Dans un chroot, il est possible de forcer les valeurs
|
# Dans un chroot, il est possible de forcer les valeurs
|
||||||
[ -n "$NUCORE_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$NUCORE_UNAME_SYSTEM"
|
[ -n "$NULIB_UNAME_SYSTEM" ] && eval "UNAME_SYSTEM=$NULIB_UNAME_SYSTEM"
|
||||||
[ -n "$NUCORE_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$NUCORE_UNAME_MACHINE"
|
[ -n "$NULIB_UNAME_MACHINE" ] && eval "UNAME_MACHINE=$NULIB_UNAME_MACHINE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nom d'hôte respectivement avec et sans domaine
|
# Nom d'hôte respectivement avec et sans domaine
|
||||||
|
|
|
@ -4,17 +4,17 @@ module: base.input "Fonctions de base: saisie"
|
||||||
|
|
||||||
function toienc() {
|
function toienc() {
|
||||||
# $1 étant une variable contenant une chaine encodée dans l'encoding d'entrée $2
|
# $1 étant une variable contenant une chaine encodée dans l'encoding d'entrée $2
|
||||||
# (qui vaut par défaut $NUCORE_INPUT_ENCODING), transformer cette chaine en
|
# (qui vaut par défaut $NULIB_INPUT_ENCODING), transformer cette chaine en
|
||||||
# utf-8
|
# utf-8
|
||||||
local __var="$1" __from="${2:-$NUCORE_INPUT_ENCODING}"
|
local __var="$1" __from="${2:-$NULIB_INPUT_ENCODING}"
|
||||||
if [ "$__from" != "NUCORE__UTF8" ]; then
|
if [ "$__from" != "NULIB__UTF8" ]; then
|
||||||
_setv "$__var" "$(iconv -f "$__from" -t utf-8 <<<"${!__var}")"
|
_setv "$__var" "$(iconv -f "$__from" -t utf-8 <<<"${!__var}")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function uread() {
|
function uread() {
|
||||||
# Lire une valeur sur stdin et la placer dans la variable $1. On assume que la
|
# Lire une valeur sur stdin et la placer dans la variable $1. On assume que la
|
||||||
# valeur en entrée est encodée dans $NUCORE_INPUT_ENCODING
|
# valeur en entrée est encodée dans $NULIB_INPUT_ENCODING
|
||||||
[ $# -gt 0 ] || set -- REPLY
|
[ $# -gt 0 ] || set -- REPLY
|
||||||
local __var
|
local __var
|
||||||
read "$@"
|
read "$@"
|
||||||
|
@ -165,7 +165,7 @@ function read_value() {
|
||||||
# affichée, ce qui la rend appropriée pour la lecture d'un mot de passe.
|
# affichée, ce qui la rend appropriée pour la lecture d'un mot de passe.
|
||||||
local -a __rv_opts; local __rv_readline=1 __rv_showdef=1 __rv_nl=
|
local -a __rv_opts; local __rv_readline=1 __rv_showdef=1 __rv_nl=
|
||||||
__rv_opts=()
|
__rv_opts=()
|
||||||
[ -n "$NUCORE_NO_READLINE" ] && __rv_readline=
|
[ -n "$NULIB_NO_READLINE" ] && __rv_readline=
|
||||||
__rv_read "$@"
|
__rv_read "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
module: base.output "Fonctions de base: affichage"
|
module: base.output "Fonctions de base: affichage"
|
||||||
|
|
||||||
NUCORE__TAB=$'\t'
|
NULIB__TAB=$'\t'
|
||||||
NUCORE__LATIN1=iso-8859-1
|
NULIB__LATIN1=iso-8859-1
|
||||||
NUCORE__LATIN9=iso-8859-15
|
NULIB__LATIN9=iso-8859-15
|
||||||
NUCORE__UTF8=utf-8
|
NULIB__UTF8=utf-8
|
||||||
|
|
||||||
if [ ! -x "$(which iconv 2>/dev/null)" ]; then
|
if [ ! -x "$(which iconv 2>/dev/null)" ]; then
|
||||||
function iconv() { cat; }
|
function iconv() { cat; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function nucore__lang_encoding() {
|
function nulib__lang_encoding() {
|
||||||
case "${LANG,,}" in
|
case "${LANG,,}" in
|
||||||
*@euro) echo "iso-8859-15";;
|
*@euro) echo "iso-8859-15";;
|
||||||
*.utf-8|*.utf8) echo "utf-8";;
|
*.utf-8|*.utf8) echo "utf-8";;
|
||||||
|
@ -19,7 +19,7 @@ function nucore__lang_encoding() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function nucore__norm_encoding() {
|
function nulib__norm_encoding() {
|
||||||
local enc="${1,,}"
|
local enc="${1,,}"
|
||||||
enc="${enc//[-_]/}"
|
enc="${enc//[-_]/}"
|
||||||
case "$enc" in
|
case "$enc" in
|
||||||
|
@ -30,16 +30,16 @@ function nucore__norm_encoding() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function nucore__init_encoding() {
|
function nulib__init_encoding() {
|
||||||
local default_encoding="$(nucore__lang_encoding)"
|
local default_encoding="$(nulib__lang_encoding)"
|
||||||
[ -n "$default_encoding" ] || default_encoding=utf-8
|
[ -n "$default_encoding" ] || default_encoding=utf-8
|
||||||
[ -n "$NUCORE_OUTPUT_ENCODING" ] || NUCORE_OUTPUT_ENCODING="$default_encoding"
|
[ -n "$NULIB_OUTPUT_ENCODING" ] || NULIB_OUTPUT_ENCODING="$default_encoding"
|
||||||
NUCORE_OUTPUT_ENCODING="$(nucore__norm_encoding "$NUCORE_OUTPUT_ENCODING")"
|
NULIB_OUTPUT_ENCODING="$(nulib__norm_encoding "$NULIB_OUTPUT_ENCODING")"
|
||||||
[ -n "$NUCORE_INPUT_ENCODING" ] || NUCORE_INPUT_ENCODING="$NUCORE_OUTPUT_ENCODING"
|
[ -n "$NULIB_INPUT_ENCODING" ] || NULIB_INPUT_ENCODING="$NULIB_OUTPUT_ENCODING"
|
||||||
NUCORE_INPUT_ENCODING="$(nucore__norm_encoding "$NUCORE_INPUT_ENCODING")"
|
NULIB_INPUT_ENCODING="$(nulib__norm_encoding "$NULIB_INPUT_ENCODING")"
|
||||||
}
|
}
|
||||||
[ -n "$NUCORE_LANG" -a -z "$LANG" ] && export NUCORE_LANG LANG="$NUCORE_LANG"
|
[ -n "$NULIB_LANG" -a -z "$LANG" ] && export NULIB_LANG LANG="$NULIB_LANG"
|
||||||
nucore__init_encoding
|
nulib__init_encoding
|
||||||
|
|
||||||
function noerror() {
|
function noerror() {
|
||||||
# lancer la commande "$@" et masquer son code de retour
|
# lancer la commande "$@" et masquer son code de retour
|
||||||
|
@ -83,9 +83,9 @@ function err_isatty() {
|
||||||
|
|
||||||
function tooenc() {
|
function tooenc() {
|
||||||
# $1 étant une chaine encodée en utf-8, l'afficher dans l'encoding de sortie $2
|
# $1 étant une chaine encodée en utf-8, l'afficher dans l'encoding de sortie $2
|
||||||
# qui vaut par défaut $NUCORE_OUTPUT_ENCODING
|
# qui vaut par défaut $NULIB_OUTPUT_ENCODING
|
||||||
local value="$1" to="${2:-$NUCORE_OUTPUT_ENCODING}"
|
local value="$1" to="${2:-$NULIB_OUTPUT_ENCODING}"
|
||||||
if [ "$to" == "$NUCORE__UTF8" ]; then
|
if [ "$to" == "$NULIB__UTF8" ]; then
|
||||||
recho "$value"
|
recho "$value"
|
||||||
else
|
else
|
||||||
iconv -f -utf-8 -t "$to" <<<"$value"
|
iconv -f -utf-8 -t "$to" <<<"$value"
|
||||||
|
@ -95,9 +95,9 @@ function uecho() { tooenc "$*"; }
|
||||||
|
|
||||||
function tooenc_() {
|
function tooenc_() {
|
||||||
# $1 étant une chaine encodée en utf-8, l'afficher sans passer à la ligne dans
|
# $1 étant une chaine encodée en utf-8, l'afficher sans passer à la ligne dans
|
||||||
# l'encoding de sortie $2 qui vaut par défaut $NUCORE_OUTPUT_ENCODING
|
# l'encoding de sortie $2 qui vaut par défaut $NULIB_OUTPUT_ENCODING
|
||||||
local value="$1" to="${2:-$NUCORE_OUTPUT_ENCODING}"
|
local value="$1" to="${2:-$NULIB_OUTPUT_ENCODING}"
|
||||||
if [ "$to" == "$NUCORE__UTF8" ]; then
|
if [ "$to" == "$NULIB__UTF8" ]; then
|
||||||
recho_ "$value"
|
recho_ "$value"
|
||||||
else
|
else
|
||||||
recho_ "$value" | iconv -f utf-8 -t "$to"
|
recho_ "$value" | iconv -f utf-8 -t "$to"
|
||||||
|
@ -106,34 +106,34 @@ function tooenc_() {
|
||||||
function uecho_() { tooenc_ "$*"; }
|
function uecho_() { tooenc_ "$*"; }
|
||||||
|
|
||||||
# faut-il dater les messages de etitle, estep, ebegin?
|
# faut-il dater les messages de etitle, estep, ebegin?
|
||||||
# Faire NUCORE_EDATE=1 en début de script pour activer cette fonctionnalité
|
# Faire NULIB_EDATE=1 en début de script pour activer cette fonctionnalité
|
||||||
export NUCORE_EDATE
|
export NULIB_EDATE
|
||||||
function __edate() { [ -n "$NUCORE_EDATE" ] && date +"[%d/%m/%Y-%H:%M:%S] "; }
|
function __edate() { [ -n "$NULIB_EDATE" ] && date +"[%d/%m/%Y-%H:%M:%S] "; }
|
||||||
|
|
||||||
export NUCORE_ELOG_OVERWRITE
|
export NULIB_ELOG_OVERWRITE
|
||||||
function __set_no_colors() { :; }
|
function __set_no_colors() { :; }
|
||||||
function elogto() {
|
function elogto() {
|
||||||
# Activer NUCORE_EDATE et rediriger STDOUT et STDERR vers le fichier $1
|
# Activer NULIB_EDATE et rediriger STDOUT et STDERR vers le fichier $1
|
||||||
# Si deux fichiers sont spécifiés, rediriger STDOUT vers $1 et STDERR vers $2
|
# Si deux fichiers sont spécifiés, rediriger STDOUT vers $1 et STDERR vers $2
|
||||||
# Si aucun fichier n'est spécifié, ne pas faire de redirection
|
# Si aucun fichier n'est spécifié, ne pas faire de redirection
|
||||||
# Si la redirection est activée, forcer l'utilisation de l'encoding UTF8
|
# Si la redirection est activée, forcer l'utilisation de l'encoding UTF8
|
||||||
# Si NUCORE_ELOG_OVERWRITE=1, alors le fichier en sortie est écrasé. Sinon, les
|
# Si NULIB_ELOG_OVERWRITE=1, alors le fichier en sortie est écrasé. Sinon, les
|
||||||
# lignes en sortie lui sont ajoutées
|
# lignes en sortie lui sont ajoutées
|
||||||
NUCORE_EDATE=1
|
NULIB_EDATE=1
|
||||||
if [ -n "$1" -a -n "$2" ]; then
|
if [ -n "$1" -a -n "$2" ]; then
|
||||||
LANG=fr_FR.UTF8
|
LANG=fr_FR.UTF8
|
||||||
NUCORE_OUTPUT_ENCODING="$NUCORE__UTF8"
|
NULIB_OUTPUT_ENCODING="$NULIB__UTF8"
|
||||||
__set_no_colors 1
|
__set_no_colors 1
|
||||||
if [ -n "$NUCORE_ELOG_OVERWRITE" ]; then
|
if [ -n "$NULIB_ELOG_OVERWRITE" ]; then
|
||||||
exec >"$1" 2>"$2"
|
exec >"$1" 2>"$2"
|
||||||
else
|
else
|
||||||
exec >>"$1" 2>>"$2"
|
exec >>"$1" 2>>"$2"
|
||||||
fi
|
fi
|
||||||
elif [ -n "$1" ]; then
|
elif [ -n "$1" ]; then
|
||||||
LANG=fr_FR.UTF8
|
LANG=fr_FR.UTF8
|
||||||
NUCORE_OUTPUT_ENCODING="$NUCORE__UTF8"
|
NULIB_OUTPUT_ENCODING="$NULIB__UTF8"
|
||||||
__set_no_colors 1
|
__set_no_colors 1
|
||||||
if [ -n "$NUCORE_ELOG_OVERWRITE" ]; then
|
if [ -n "$NULIB_ELOG_OVERWRITE" ]; then
|
||||||
exec >"$1" 2>&1
|
exec >"$1" 2>&1
|
||||||
else
|
else
|
||||||
exec >>"$1" 2>&1
|
exec >>"$1" 2>&1
|
||||||
|
@ -142,35 +142,35 @@ function elogto() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# variables utilisées pour l'affichage indenté des messages et des titres
|
# variables utilisées pour l'affichage indenté des messages et des titres
|
||||||
# NUCORE__ESTACK est la liste des invocations de 'ebegin' et 'etitle' en cours
|
# NULIB__ESTACK est la liste des invocations de 'ebegin' et 'etitle' en cours
|
||||||
# NUCORE__TLEVEL est l'indentation à appliquer avant d'afficher le message
|
# NULIB__TLEVEL est l'indentation à appliquer avant d'afficher le message
|
||||||
export NUCORE__ESTACK NUCORE__TLEVEL
|
export NULIB__ESTACK NULIB__TLEVEL
|
||||||
function __indent() {
|
function __indent() {
|
||||||
# indenter les lignes de $1, sauf la première
|
# indenter les lignes de $1, sauf la première
|
||||||
if [ "${1/
|
if [ "${1/
|
||||||
/}" != "$1" ]; then
|
/}" != "$1" ]; then
|
||||||
sed "2,\$s/^/${NUCORE__TLEVEL}/g" <<<"$1"
|
sed "2,\$s/^/${NULIB__TLEVEL}/g" <<<"$1"
|
||||||
else
|
else
|
||||||
recho "$1"
|
recho "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# fonctions à surcharger pour modifier la façon dont les messages sont affichés
|
# fonctions à surcharger pour modifier la façon dont les messages sont affichés
|
||||||
function __eerror() { tooenc "$(__edate)${NUCORE__TLEVEL}ERROR $(__indent "$1")"; }
|
function __eerror() { tooenc "$(__edate)${NULIB__TLEVEL}ERROR $(__indent "$1")"; }
|
||||||
function __ewarn() { tooenc "$(__edate)${NUCORE__TLEVEL}WARNING $(__indent "$1")"; }
|
function __ewarn() { tooenc "$(__edate)${NULIB__TLEVEL}WARNING $(__indent "$1")"; }
|
||||||
function __enote() { tooenc "$(__edate)${NUCORE__TLEVEL}NOTE $(__indent "$1")"; }
|
function __enote() { tooenc "$(__edate)${NULIB__TLEVEL}NOTE $(__indent "$1")"; }
|
||||||
function __ebanner() {
|
function __ebanner() {
|
||||||
local maxi="${COLUMNS:-80}"
|
local maxi="${COLUMNS:-80}"
|
||||||
local -a lines
|
local -a lines
|
||||||
local psfix line
|
local psfix line
|
||||||
|
|
||||||
psfix="$(__edate)${NUCORE__TLEVEL}"
|
psfix="$(__edate)${NULIB__TLEVEL}"
|
||||||
while [ ${#psfix} -lt $maxi ]; do psfix="$psfix="; done
|
while [ ${#psfix} -lt $maxi ]; do psfix="$psfix="; done
|
||||||
|
|
||||||
tooenc "$psfix"
|
tooenc "$psfix"
|
||||||
maxi=$(($maxi - 1))
|
maxi=$(($maxi - 1))
|
||||||
array_xsplitl lines "$1"
|
array_xsplitl lines "$1"
|
||||||
for line in "" "${lines[@]}" ""; do
|
for line in "" "${lines[@]}" ""; do
|
||||||
line="$(__edate)${NUCORE__TLEVEL}= $line"
|
line="$(__edate)${NULIB__TLEVEL}= $line"
|
||||||
if [ ${#line} -le $maxi ]; then
|
if [ ${#line} -le $maxi ]; then
|
||||||
while [ ${#line} -lt $maxi ]; do line="$line "; done
|
while [ ${#line} -lt $maxi ]; do line="$line "; done
|
||||||
line="$line="
|
line="$line="
|
||||||
|
@ -179,24 +179,24 @@ function __ebanner() {
|
||||||
done
|
done
|
||||||
tooenc "$psfix"
|
tooenc "$psfix"
|
||||||
}
|
}
|
||||||
function __eimportant() { tooenc "$(__edate)${NUCORE__TLEVEL}IMPORTANT $(__indent "$1")"; }
|
function __eimportant() { tooenc "$(__edate)${NULIB__TLEVEL}IMPORTANT $(__indent "$1")"; }
|
||||||
function __eattention() { tooenc "$(__edate)${NUCORE__TLEVEL}ATTENTION $(__indent "$1")"; }
|
function __eattention() { tooenc "$(__edate)${NULIB__TLEVEL}ATTENTION $(__indent "$1")"; }
|
||||||
function __einfo() { tooenc "$(__edate)${NUCORE__TLEVEL}INFO $(__indent "$1")"; }
|
function __einfo() { tooenc "$(__edate)${NULIB__TLEVEL}INFO $(__indent "$1")"; }
|
||||||
function __eecho() { tooenc "$(__edate)${NUCORE__TLEVEL}$(__indent "$1")"; }
|
function __eecho() { tooenc "$(__edate)${NULIB__TLEVEL}$(__indent "$1")"; }
|
||||||
function __eecho_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}$(__indent "$1")"; }
|
function __eecho_() { tooenc_ "$(__edate)${NULIB__TLEVEL}$(__indent "$1")"; }
|
||||||
function __edebug() { tooenc "$(__edate)${NUCORE__TLEVEL}DEBUG $(__indent "$1")"; }
|
function __edebug() { tooenc "$(__edate)${NULIB__TLEVEL}DEBUG $(__indent "$1")"; }
|
||||||
function __estep() { tooenc "$(__edate)${NUCORE__TLEVEL}. $(__indent "$1")"; }
|
function __estep() { tooenc "$(__edate)${NULIB__TLEVEL}. $(__indent "$1")"; }
|
||||||
function __estepe() { tooenc "$(__edate)${NUCORE__TLEVEL}.E $(__indent "$1")"; }
|
function __estepe() { tooenc "$(__edate)${NULIB__TLEVEL}.E $(__indent "$1")"; }
|
||||||
function __estepw() { tooenc "$(__edate)${NUCORE__TLEVEL}.W $(__indent "$1")"; }
|
function __estepw() { tooenc "$(__edate)${NULIB__TLEVEL}.W $(__indent "$1")"; }
|
||||||
function __estepn() { tooenc "$(__edate)${NUCORE__TLEVEL}.N $(__indent "$1")"; }
|
function __estepn() { tooenc "$(__edate)${NULIB__TLEVEL}.N $(__indent "$1")"; }
|
||||||
function __estepi() { tooenc "$(__edate)${NUCORE__TLEVEL}.I $(__indent "$1")"; }
|
function __estepi() { tooenc "$(__edate)${NULIB__TLEVEL}.I $(__indent "$1")"; }
|
||||||
function __estep_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}. $(__indent "$1")"; }
|
function __estep_() { tooenc_ "$(__edate)${NULIB__TLEVEL}. $(__indent "$1")"; }
|
||||||
function __estepe_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}.E $(__indent "$1")"; }
|
function __estepe_() { tooenc_ "$(__edate)${NULIB__TLEVEL}.E $(__indent "$1")"; }
|
||||||
function __estepw_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}.W $(__indent "$1")"; }
|
function __estepw_() { tooenc_ "$(__edate)${NULIB__TLEVEL}.W $(__indent "$1")"; }
|
||||||
function __estepn_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}.N $(__indent "$1")"; }
|
function __estepn_() { tooenc_ "$(__edate)${NULIB__TLEVEL}.N $(__indent "$1")"; }
|
||||||
function __estepi_() { tooenc_ "$(__edate)${NUCORE__TLEVEL}.I $(__indent "$1")"; }
|
function __estepi_() { tooenc_ "$(__edate)${NULIB__TLEVEL}.I $(__indent "$1")"; }
|
||||||
function __etitle() { tooenc "$(__edate)${NUCORE__TLEVEL}=== $(__indent "$1")"; }
|
function __etitle() { tooenc "$(__edate)${NULIB__TLEVEL}=== $(__indent "$1")"; }
|
||||||
function __ebegin() { tooenc_ "$(__edate)${NUCORE__TLEVEL}. $(__indent "$1"): "; }
|
function __ebegin() { tooenc_ "$(__edate)${NULIB__TLEVEL}. $(__indent "$1"): "; }
|
||||||
function __edoto() { echo_ "."; }
|
function __edoto() { echo_ "."; }
|
||||||
function __edotw() { echo_ "w"; }
|
function __edotw() { echo_ "w"; }
|
||||||
function __edotx() { echo_ "x"; }
|
function __edotx() { echo_ "x"; }
|
||||||
|
@ -230,14 +230,14 @@ function check_verbosity() {
|
||||||
function get_verbosity_option() { :;}
|
function get_verbosity_option() { :;}
|
||||||
|
|
||||||
# note: toutes les fonctions d'affichage e* écrivent sur stderr
|
# note: toutes les fonctions d'affichage e* écrivent sur stderr
|
||||||
NUCORE__EPENDING=
|
NULIB__EPENDING=
|
||||||
function eflush() {
|
function eflush() {
|
||||||
# Afficher les messages en attente
|
# Afficher les messages en attente
|
||||||
if [ -n "$NUCORE__EPENDING" ]; then recho "$NUCORE__EPENDING" 1>&2; NUCORE__EPENDING=; fi
|
if [ -n "$NULIB__EPENDING" ]; then recho "$NULIB__EPENDING" 1>&2; NULIB__EPENDING=; fi
|
||||||
}
|
}
|
||||||
function eclearp() {
|
function eclearp() {
|
||||||
# Supprimer les message en attente
|
# Supprimer les message en attente
|
||||||
NUCORE__EPENDING=
|
NULIB__EPENDING=
|
||||||
}
|
}
|
||||||
function eerror() {
|
function eerror() {
|
||||||
# Afficher un message d'erreur
|
# Afficher un message d'erreur
|
||||||
|
@ -429,11 +429,11 @@ function __t_etitle() {
|
||||||
local __t_title="$1"; shift
|
local __t_title="$1"; shift
|
||||||
local __t_s=0
|
local __t_s=0
|
||||||
# etitle
|
# etitle
|
||||||
[ -n "$NUCORE__ESTACK" ] && NUCORE__TLEVEL="${NUCORE__TLEVEL} "
|
[ -n "$NULIB__ESTACK" ] && NULIB__TLEVEL="${NULIB__TLEVEL} "
|
||||||
NUCORE__ESTACK="$NUCORE__ESTACK:t"
|
NULIB__ESTACK="$NULIB__ESTACK:t"
|
||||||
if show_info; then
|
if show_info; then
|
||||||
if [ -n "$__t_deferred" ]; then
|
if [ -n "$__t_deferred" ]; then
|
||||||
NUCORE__EPENDING="${NUCORE__EPENDING:+$NUCORE__EPENDING
|
NULIB__EPENDING="${NULIB__EPENDING:+$NULIB__EPENDING
|
||||||
}$(__etitle "$__t_title")"
|
}$(__etitle "$__t_title")"
|
||||||
else
|
else
|
||||||
eflush
|
eflush
|
||||||
|
@ -512,7 +512,7 @@ function ebegin() {
|
||||||
local __b_msg="$1"; shift
|
local __b_msg="$1"; shift
|
||||||
local __b_s=0
|
local __b_s=0
|
||||||
# ebegin
|
# ebegin
|
||||||
NUCORE__ESTACK="$NUCORE__ESTACK:b"
|
NULIB__ESTACK="$NULIB__ESTACK:b"
|
||||||
if show_info; then
|
if show_info; then
|
||||||
eflush
|
eflush
|
||||||
__ebegin "$__b_msg" 1>&2
|
__ebegin "$__b_msg" 1>&2
|
||||||
|
@ -597,11 +597,11 @@ function eend() {
|
||||||
# par le titre.
|
# par le titre.
|
||||||
local s=$?
|
local s=$?
|
||||||
if [ "$1" == "-c" ]; then
|
if [ "$1" == "-c" ]; then
|
||||||
NUCORE__ESTACK=
|
NULIB__ESTACK=
|
||||||
NUCORE__TLEVEL=
|
NULIB__TLEVEL=
|
||||||
elif [ "${NUCORE__ESTACK%:b}" != "$NUCORE__ESTACK" ]; then
|
elif [ "${NULIB__ESTACK%:b}" != "$NULIB__ESTACK" ]; then
|
||||||
# terminer ebegin
|
# terminer ebegin
|
||||||
NUCORE__ESTACK="${NUCORE__ESTACK%:b}"
|
NULIB__ESTACK="${NULIB__ESTACK%:b}"
|
||||||
show_info || return
|
show_info || return
|
||||||
eflush
|
eflush
|
||||||
[ -n "$1" ] && s="$1"
|
[ -n "$1" ] && s="$1"
|
||||||
|
@ -610,10 +610,10 @@ function eend() {
|
||||||
else
|
else
|
||||||
__eendx 1>&2
|
__eendx 1>&2
|
||||||
fi
|
fi
|
||||||
elif [ "${NUCORE__ESTACK%:t}" != "$NUCORE__ESTACK" ]; then
|
elif [ "${NULIB__ESTACK%:t}" != "$NULIB__ESTACK" ]; then
|
||||||
# terminer etitle -s
|
# terminer etitle -s
|
||||||
NUCORE__ESTACK="${NUCORE__ESTACK%:t}"
|
NULIB__ESTACK="${NULIB__ESTACK%:t}"
|
||||||
NUCORE__TLEVEL="${NUCORE__TLEVEL% }"
|
NULIB__TLEVEL="${NULIB__TLEVEL% }"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function __elinedots() {
|
function __elinedots() {
|
||||||
|
|
|
@ -55,11 +55,11 @@ function mktempd() {
|
||||||
mktemp -d "${1:-"$TMPDIR/tmp.XXXXXX"}"
|
mktemp -d "${1:-"$TMPDIR/tmp.XXXXXX"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ac__forgetall() { NUCORE__AC_FILES=(); }
|
function ac__forgetall() { NULIB__AC_FILES=(); }
|
||||||
ac__forgetall
|
ac__forgetall
|
||||||
function ac__trap() {
|
function ac__trap() {
|
||||||
local file
|
local file
|
||||||
for file in "${NUCORE__AC_FILES[@]}"; do
|
for file in "${NULIB__AC_FILES[@]}"; do
|
||||||
[ -e "$file" ] && rm -rf "$file" 2>/dev/null
|
[ -e "$file" ] && rm -rf "$file" 2>/dev/null
|
||||||
done
|
done
|
||||||
ac__forgetall
|
ac__forgetall
|
||||||
|
@ -72,7 +72,7 @@ programme"
|
||||||
function autoclean() {
|
function autoclean() {
|
||||||
local file
|
local file
|
||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
[ -n "$file" ] && NUCORE__AC_FILES=("${NUCORE__AC_FILES[@]}" "$file")
|
[ -n "$file" ] && NULIB__AC_FILES=("${NULIB__AC_FILES[@]}" "$file")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ par ac_set_tmpfile() ou ac_set_tmpdir()"
|
||||||
function ac_clean() {
|
function ac_clean() {
|
||||||
local file acfile found
|
local file acfile found
|
||||||
local -a acfiles
|
local -a acfiles
|
||||||
for acfile in "${NUCORE__AC_FILES[@]}"; do
|
for acfile in "${NULIB__AC_FILES[@]}"; do
|
||||||
found=
|
found=
|
||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
if [ "$file" == "$acfile" ]; then
|
if [ "$file" == "$acfile" ]; then
|
||||||
|
@ -99,7 +99,7 @@ function ac_clean() {
|
||||||
done
|
done
|
||||||
[ -z "$found" ] && acfiles=("${acfiles[@]}" "$acfile")
|
[ -z "$found" ] && acfiles=("${acfiles[@]}" "$acfile")
|
||||||
done
|
done
|
||||||
NUCORE__AC_FILES=("${acfiles[@]}")
|
NULIB__AC_FILES=("${acfiles[@]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
function: ac_set_tmpfile "\
|
function: ac_set_tmpfile "\
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
# shim pour les fonctions de nucore.sh au cas où ce module n'est pas chargée
|
# shim pour les fonctions de nulib.sh au cas où ce module n'est pas chargée
|
||||||
if [ -z "$NUCOREDIR" -o "$NUCOREDIR" != "$NUCOREINIT" ]; then
|
if [ -z "$NULIBDIR" -o "$NULIBDIR" != "$NULIBINIT" ]; then
|
||||||
function module:() { :; }
|
function module:() { :; }
|
||||||
function function:() { :; }
|
function function:() { :; }
|
||||||
function require:() { :; }
|
function require:() { :; }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
##@require nucore.sh
|
##@require nulib.sh
|
||||||
##@require base
|
##@require base
|
||||||
module: git "Fonctions pour faciliter l'utilisation de git"
|
module: git "Fonctions pour faciliter l'utilisation de git"
|
||||||
require: nucore base
|
require: nulib base
|
||||||
|
|
||||||
function: git_geturl ""
|
function: git_geturl ""
|
||||||
function git_geturl() {
|
function git_geturl() {
|
||||||
|
@ -15,7 +15,7 @@ function git_have_annex() {
|
||||||
[ -n "$(git config --get annex.uuid)" ]
|
[ -n "$(git config --get annex.uuid)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
NUCORE_GIT_FUNCTIONS=(
|
NULIB_GIT_FUNCTIONS=(
|
||||||
git_check_gitvcs git_ensure_gitvcs
|
git_check_gitvcs git_ensure_gitvcs
|
||||||
git_list_branches git_list_rbranches
|
git_list_branches git_list_rbranches
|
||||||
git_have_branch git_have_rbranch
|
git_have_branch git_have_rbranch
|
||||||
|
@ -25,7 +25,7 @@ NUCORE_GIT_FUNCTIONS=(
|
||||||
git_is_ancestor git_should_ff git_should_push
|
git_is_ancestor git_should_ff git_should_push
|
||||||
git_is_merged
|
git_is_merged
|
||||||
)
|
)
|
||||||
NUCORE_GIT_FUNCTIONS_MAP=(
|
NULIB_GIT_FUNCTIONS_MAP=(
|
||||||
cg:git_check_gitvcs eg:git_ensure_gitvcs
|
cg:git_check_gitvcs eg:git_ensure_gitvcs
|
||||||
lbs:git_list_branches rbs:git_list_rbranches
|
lbs:git_list_branches rbs:git_list_rbranches
|
||||||
hlb:git_have_branch hrb:git_have_rbranch
|
hlb:git_have_branch hrb:git_have_rbranch
|
||||||
|
@ -148,7 +148,7 @@ function git_ensure_branch() {
|
||||||
# créer une nouvelle branche du nom spécifié
|
# créer une nouvelle branche du nom spécifié
|
||||||
git_have_branch "$source" || return 2
|
git_have_branch "$source" || return 2
|
||||||
git branch "$branch" "$source" || return 2
|
git branch "$branch" "$source" || return 2
|
||||||
if [ -z "$NUCORE_GIT_OFFLINE" ]; then
|
if [ -z "$NULIB_GIT_OFFLINE" ]; then
|
||||||
git_have_remote "$origin" && git_track_branch "$branch" "$origin"
|
git_have_remote "$origin" && git_track_branch "$branch" "$origin"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -219,16 +219,16 @@ function git_is_merged() {
|
||||||
################################################################################
|
################################################################################
|
||||||
# git annex
|
# git annex
|
||||||
|
|
||||||
NUCORE_GIT_SSH_WRAPPER=
|
NULIB_GIT_SSH_WRAPPER=
|
||||||
function: git_annex_use_ssh_wrapper ""
|
function: git_annex_use_ssh_wrapper ""
|
||||||
function git_annex_use_ssh_wrapper() {
|
function git_annex_use_ssh_wrapper() {
|
||||||
[ -n "$NUCORE_GIT_SSH_WRAPPER" ] && return
|
[ -n "$NULIB_GIT_SSH_WRAPPER" ] && return
|
||||||
NUCORE_GIT_FORCE_PATH="$PATH"
|
NULIB_GIT_FORCE_PATH="$PATH"
|
||||||
NUCORE_GIT_FORCE_SSH="${GIT_SSH:-ssh}"
|
NULIB_GIT_FORCE_SSH="${GIT_SSH:-ssh}"
|
||||||
export NUCORE_GIT_FORCE_PATH NUCORE_GIT_FORCE_SSH
|
export NULIB_GIT_FORCE_PATH NULIB_GIT_FORCE_SSH
|
||||||
base_delpath "$NUCOREDIR/ssh-wrapper" NUCORE_GIT_FORCE_PATH
|
base_delpath "$NULIBDIR/ssh-wrapper" NULIB_GIT_FORCE_PATH
|
||||||
base_inspath "$NUCOREDIR/ssh-wrapper" PATH
|
base_inspath "$NULIBDIR/ssh-wrapper" PATH
|
||||||
NUCORE_GIT_SSH_WRAPPER=1
|
NULIB_GIT_SSH_WRAPPER=1
|
||||||
}
|
}
|
||||||
|
|
||||||
function: git_annex_initial "sur le dépôt \$1 fraichement cloné, vérifier s'il faut faire git annex init. Si oui, l'initialiser avec le nom d'hôte, et récupérer tous les fichiers annexés
|
function: git_annex_initial "sur le dépôt \$1 fraichement cloné, vérifier s'il faut faire git annex init. Si oui, l'initialiser avec le nom d'hôte, et récupérer tous les fichiers annexés
|
||||||
|
@ -274,7 +274,7 @@ function git_annex_initial() {
|
||||||
function: git_commit ""
|
function: git_commit ""
|
||||||
function git_commit() {
|
function git_commit() {
|
||||||
local all=auto allnew push=auto nopush args
|
local all=auto allnew push=auto nopush args
|
||||||
setyesval nopush "$NUCORE_GIT_OFFLINE"
|
setyesval nopush "$NULIB_GIT_OFFLINE"
|
||||||
[ -n "$nopush" ] && push=
|
[ -n "$nopush" ] && push=
|
||||||
parse_opts + "${PRETTYOPTS[@]}" \
|
parse_opts + "${PRETTYOPTS[@]}" \
|
||||||
-a,--all all=1 \
|
-a,--all all=1 \
|
||||||
|
|
|
@ -49,7 +49,7 @@ function get_color() {
|
||||||
}
|
}
|
||||||
function __set_no_colors() {
|
function __set_no_colors() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
if [ -n "$NUCORE_NO_COLORS" ]; then NO_COLORS=1
|
if [ -n "$NULIB_NO_COLORS" ]; then NO_COLORS=1
|
||||||
elif out_isatty && err_isatty; then NO_COLORS=
|
elif out_isatty && err_isatty; then NO_COLORS=
|
||||||
else NO_COLORS=1
|
else NO_COLORS=1
|
||||||
fi
|
fi
|
||||||
|
@ -65,22 +65,22 @@ function __set_no_colors() {
|
||||||
}
|
}
|
||||||
__set_no_colors
|
__set_no_colors
|
||||||
|
|
||||||
function __eerror() { local p; [ -z "$NO_COLORS" ] && p="E" || p="ERROR"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __eerror() { local p; [ -z "$NO_COLORS" ] && p="E" || p="ERROR"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __ewarn() { local p; [ -z "$NO_COLORS" ] && p="W" || p="WARNING"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __ewarn() { local p; [ -z "$NO_COLORS" ] && p="W" || p="WARNING"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __enote() { local p; [ -z "$NO_COLORS" ] && p="N" || p="NOTE"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __enote() { local p; [ -z "$NO_COLORS" ] && p="N" || p="NOTE"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __ebanner() {
|
function __ebanner() {
|
||||||
local maxi="${COLUMNS:-80}"
|
local maxi="${COLUMNS:-80}"
|
||||||
local -a lines
|
local -a lines
|
||||||
local psfix line
|
local psfix line
|
||||||
|
|
||||||
psfix="$(__edate)${NUCORE__TLEVEL}"
|
psfix="$(__edate)${NULIB__TLEVEL}"
|
||||||
while [ ${#psfix} -lt $maxi ]; do psfix="$psfix="; done
|
while [ ${#psfix} -lt $maxi ]; do psfix="$psfix="; done
|
||||||
|
|
||||||
tooenc "$COULEUR_ROUGE$psfix"
|
tooenc "$COULEUR_ROUGE$psfix"
|
||||||
maxi=$(($maxi - 1))
|
maxi=$(($maxi - 1))
|
||||||
array_xsplitl lines "$1"
|
array_xsplitl lines "$1"
|
||||||
for line in "" "${lines[@]}" ""; do
|
for line in "" "${lines[@]}" ""; do
|
||||||
line="$(__edate)${NUCORE__TLEVEL}= $line"
|
line="$(__edate)${NULIB__TLEVEL}= $line"
|
||||||
if [ ${#line} -le $maxi ]; then
|
if [ ${#line} -le $maxi ]; then
|
||||||
while [ ${#line} -lt $maxi ]; do line="$line "; done
|
while [ ${#line} -lt $maxi ]; do line="$line "; done
|
||||||
line="$line="
|
line="$line="
|
||||||
|
@ -89,22 +89,22 @@ function __ebanner() {
|
||||||
done
|
done
|
||||||
tooenc "$psfix$COULEUR_NORMALE"
|
tooenc "$psfix$COULEUR_NORMALE"
|
||||||
}
|
}
|
||||||
function __eimportant() { local p; [ -z "$NO_COLORS" ] && p="!" || p="IMPORTANT"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __eimportant() { local p; [ -z "$NO_COLORS" ] && p="!" || p="IMPORTANT"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __eattention() { local p; [ -z "$NO_COLORS" ] && p="*" || p="ATTENTION"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __eattention() { local p; [ -z "$NO_COLORS" ] && p="*" || p="ATTENTION"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __einfo() { local p; [ -z "$NO_COLORS" ] && p="I" || p="INFO"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __einfo() { local p; [ -z "$NO_COLORS" ] && p="I" || p="INFO"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __edebug() { local p; [ -z "$NO_COLORS" ] && p="D" || p="DEBUG"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __edebug() { local p; [ -z "$NO_COLORS" ] && p="D" || p="DEBUG"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estep() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estep() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepe() { local p; [ -z "$NO_COLORS" ] && p="." || p=".E"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepe() { local p; [ -z "$NO_COLORS" ] && p="." || p=".E"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepw() { local p; [ -z "$NO_COLORS" ] && p="." || p=".W"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepw() { local p; [ -z "$NO_COLORS" ] && p="." || p=".W"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepn() { local p; [ -z "$NO_COLORS" ] && p="." || p=".N"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepn() { local p; [ -z "$NO_COLORS" ] && p="." || p=".N"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepi() { local p; [ -z "$NO_COLORS" ] && p="." || p=".I"; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepi() { local p; [ -z "$NO_COLORS" ] && p="." || p=".I"; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estep_() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estep_() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepe_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".E"; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepe_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".E"; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_ROUGE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepw_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".W"; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepw_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".W"; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_JAUNE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepn_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".N"; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepn_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".N"; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_VERTE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __estepi_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".I"; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
function __estepi_() { local p; [ -z "$NO_COLORS" ] && p="." || p=".I"; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_BLEUE}${p}${COULEUR_NORMALE} $(__indent "$1")"; }
|
||||||
function __etitle() { local p; [ -z "$NO_COLORS" ] && p="T" || p="==="; tooenc "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLEUE}${p} $(get_color _)$(__indent "$1")${COULEUR_NORMALE}"; }
|
function __etitle() { local p; [ -z "$NO_COLORS" ] && p="T" || p="==="; tooenc "$(__edate)${NULIB__TLEVEL}${COULEUR_BLEUE}${p} $(get_color _)$(__indent "$1")${COULEUR_NORMALE}"; }
|
||||||
function __ebegin() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc_ "$(__edate)${NUCORE__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1"): "; }
|
function __ebegin() { local p; [ -z "$NO_COLORS" ] && p="." || p="."; tooenc_ "$(__edate)${NULIB__TLEVEL}${COULEUR_BLANCHE}${p}${COULEUR_NORMALE} $(__indent "$1"): "; }
|
||||||
function __edoto() { echo_ "."; }
|
function __edoto() { echo_ "."; }
|
||||||
function __edotw() { echo_ "${COULEUR_JAUNE}w${COULEUR_NORMALE}"; }
|
function __edotw() { echo_ "${COULEUR_JAUNE}w${COULEUR_NORMALE}"; }
|
||||||
function __edotx() { echo_ "${COULEUR_ROUGE}x${COULEUR_NORMALE}"; }
|
function __edotx() { echo_ "${COULEUR_ROUGE}x${COULEUR_NORMALE}"; }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname -- "$0")/../src/nucore.sh" || exit 1
|
source "$(dirname -- "$0")/../src/nulib.sh" || exit 1
|
||||||
require: tests
|
require: tests
|
||||||
#NUCORE_NO_DISABLE_SET_X=1
|
#NULIB_NO_DISABLE_SET_X=1
|
||||||
|
|
||||||
function pa() {
|
function pa() {
|
||||||
unset count fixed mopt dmopt oopt doopt autoinc autoval a1 a2 a3 a4
|
unset count fixed mopt dmopt oopt doopt autoinc autoval a1 a2 a3 a4
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname -- "$0")/../src/nucore.sh" || exit 1
|
source "$(dirname -- "$0")/../src/nulib.sh" || exit 1
|
||||||
#NUCORE_NO_DISABLE_SET_X=1
|
#NULIB_NO_DISABLE_SET_X=1
|
||||||
|
|
||||||
eerror "erreur"
|
eerror "erreur"
|
||||||
ewarn "warning"
|
ewarn "warning"
|
||||||
|
|
|
@ -7,5 +7,5 @@ source "$(dirname -- "$0")/../load.sh" || exit 1
|
||||||
cd "$MYDIR/.."
|
cd "$MYDIR/.."
|
||||||
[ -n "$1" ] && dest="$1" || dest="$(pwd)"
|
[ -n "$1" ] && dest="$1" || dest="$(pwd)"
|
||||||
|
|
||||||
estep "Maj /etc/nucore.sh"
|
estep "Maj /etc/nulib.sh"
|
||||||
sed "s|@@""dest""@@|$dest|g" load.sh >/etc/nucore.sh
|
sed "s|@@""dest""@@|$dest|g" load.sh >/etc/nulib.sh
|
||||||
|
|
136
load.sh
136
load.sh
|
@ -1,20 +1,20 @@
|
||||||
##@cooked comments # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
##@cooked comments # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
## Charger nucore et rendre disponible les modules bash, awk, php et python
|
## Charger nulib et rendre disponible les modules bash, awk, php et python
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
# Ce fichier doit être sourcé en premier. Si ce fichier n'est pas sourcé, alors
|
# Ce fichier doit être sourcé en premier. Si ce fichier n'est pas sourcé, alors
|
||||||
# le répertoire nucore doit être disponible dans le répertoire du script qui
|
# le répertoire nulib doit être disponible dans le répertoire du script qui
|
||||||
# inclue ce fichier.
|
# inclue ce fichier.
|
||||||
# Une fois ce fichier sourcé, les autres modules peuvent être importés avec
|
# Une fois ce fichier sourcé, les autres modules peuvent être importés avec
|
||||||
# require:() e.g.
|
# require:() e.g.
|
||||||
# source /etc/nucore.sh || exit 1
|
# source /etc/nulib.sh || exit 1
|
||||||
# require: other_modules
|
# require: other_modules
|
||||||
# ou pour une copie locale de nucore:
|
# ou pour une copie locale de nulib:
|
||||||
# source "$(dirname "$0")/nucore/load.sh" || exit 1
|
# source "$(dirname "$0")/nulib/load.sh" || exit 1
|
||||||
# require: other_modules
|
# require: other_modules
|
||||||
|
|
||||||
# vérifier version minimum de bash
|
# vérifier version minimum de bash
|
||||||
if [ "x$BASH" = "x" ]; then
|
if [ "x$BASH" = "x" ]; then
|
||||||
echo "ERROR: nucore: this script requires bash"
|
echo "ERROR: nulib: this script requires bash"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -27,68 +27,68 @@ function inspathm() { local _qdir="${1//\//\\/}"; eval "export ${2:-PATH}; "'[ "
|
||||||
function inspath() { delpath "$@"; inspathm "$@"; }
|
function inspath() { delpath "$@"; inspathm "$@"; }
|
||||||
|
|
||||||
if [ ${BASH_VERSINFO[0]} -ge 5 -o \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) ]; then :
|
if [ ${BASH_VERSINFO[0]} -ge 5 -o \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) ]; then :
|
||||||
elif [ -n "$NUCORE_IGNORE_BASH_VERSION" ]; then :
|
elif [ -n "$NULIB_IGNORE_BASH_VERSION" ]; then :
|
||||||
else die "nucore: bash 4.1+ is required"
|
else die "nulib: bash 4.1+ is required"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculer emplacement de nucore
|
# Calculer emplacement de nulib
|
||||||
NUCOREDIR="@@dest@@"
|
NULIBDIR="@@dest@@"
|
||||||
if [ "$NUCOREDIR" = "@@""dest""@@" ]; then
|
if [ "$NULIBDIR" = "@@""dest""@@" ]; then
|
||||||
# La valeur "@@"dest"@@" n'est remplacée que dans la copie de ce script
|
# La valeur "@@"dest"@@" n'est remplacée que dans la copie de ce script
|
||||||
# faite dans /etc. Sinon, il faut toujours faire le calcul. Cela permet de
|
# faite dans /etc. Sinon, il faut toujours faire le calcul. Cela permet de
|
||||||
# déplacer la librairie n'importe où sur le disque, ce qui est
|
# déplacer la librairie n'importe où sur le disque, ce qui est
|
||||||
# particulièrement intéressant quand on fait du déploiement.
|
# particulièrement intéressant quand on fait du déploiement.
|
||||||
NUCOREDIR="${BASH_SOURCE[0]}"
|
NULIBDIR="${BASH_SOURCE[0]}"
|
||||||
if [ -f "$NUCOREDIR" -a "$(basename -- "$NUCOREDIR")" == load.sh ]; then
|
if [ -f "$NULIBDIR" -a "$(basename -- "$NULIBDIR")" == load.sh ]; then
|
||||||
# Fichier sourcé depuis nucore/
|
# Fichier sourcé depuis nulib/
|
||||||
NUCORE_SOURCED=1
|
NULIB_SOURCED=1
|
||||||
NUCOREDIR="$(dirname -- "$NUCOREDIR")"
|
NULIBDIR="$(dirname -- "$NULIBDIR")"
|
||||||
elif [ -f "$NUCOREDIR" -a "$(basename -- "$NUCOREDIR")" == nucore.sh ]; then
|
elif [ -f "$NULIBDIR" -a "$(basename -- "$NULIBDIR")" == nulib.sh ]; then
|
||||||
# Fichier sourcé depuis nucore/bash/src
|
# Fichier sourcé depuis nulib/bash/src
|
||||||
NUCORE_SOURCED=1
|
NULIB_SOURCED=1
|
||||||
NUCOREDIR="$(dirname -- "$NUCOREDIR")/../.."
|
NULIBDIR="$(dirname -- "$NULIBDIR")/../.."
|
||||||
else
|
else
|
||||||
# Fichier non sourcé. Tout exprimer par rapport au script courant
|
# Fichier non sourcé. Tout exprimer par rapport au script courant
|
||||||
NUCORE_SOURCED=
|
NULIB_SOURCED=
|
||||||
NUCOREDIR="$(dirname -- "$0")"
|
NULIBDIR="$(dirname -- "$0")"
|
||||||
if [ -d "$NUCOREDIR/nucore" ]; then
|
if [ -d "$NULIBDIR/nulib" ]; then
|
||||||
NUCOREDIR="$NUCOREDIR/nucore"
|
NULIBDIR="$NULIBDIR/nulib"
|
||||||
elif [ -d "$NUCOREDIR/lib/nucore" ]; then
|
elif [ -d "$NULIBDIR/lib/nulib" ]; then
|
||||||
NUCOREDIR="$NUCOREDIR/lib/nucore"
|
NULIBDIR="$NULIBDIR/lib/nulib"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "${BASH_SOURCE[0]}" = /etc/nucore.sh ]; then
|
elif [ "${BASH_SOURCE[0]}" = /etc/nulib.sh ]; then
|
||||||
# Fichier chargé depuis /etc/nucore.sh
|
# Fichier chargé depuis /etc/nulib.sh
|
||||||
NUCORE_SOURCED=1
|
NULIB_SOURCED=1
|
||||||
fi
|
fi
|
||||||
NUCOREDIR="$(cd "$NUCOREDIR" 2>/dev/null; pwd)"
|
NULIBDIR="$(cd "$NULIBDIR" 2>/dev/null; pwd)"
|
||||||
NUCOREDIRS=("$NUCOREDIR/bash/src")
|
NULIBDIRS=("$NULIBDIR/bash/src")
|
||||||
|
|
||||||
# marqueur pour vérifier que nucore a réellement été chargé. il faut avoir $NUCOREINIT == $NUCOREDIR
|
# marqueur pour vérifier que nulib a réellement été chargé. il faut avoir $NULIBINIT == $NULIBDIR
|
||||||
# utilisé par le module base qui doit pouvoir être inclus indépendamment
|
# utilisé par le module base qui doit pouvoir être inclus indépendamment
|
||||||
NUCOREINIT="$NUCOREDIR"
|
NULIBINIT="$NULIBDIR"
|
||||||
|
|
||||||
## Modules bash
|
## Modules bash
|
||||||
NUCORE_LOADED_MODULES=(nucore)
|
NULIB_LOADED_MODULES=(nulib)
|
||||||
NUCORE_DEFAULT_MODULES=(base pretty sysinfos)
|
NULIB_DEFAULT_MODULES=(base pretty sysinfos)
|
||||||
|
|
||||||
# Si cette variable est non vide, require: recharge toujours le module, même
|
# Si cette variable est non vide, require: recharge toujours le module, même
|
||||||
# s'il a déjà été chargé. Cette valeur n'est pas transitive: il faut toujours
|
# s'il a déjà été chargé. Cette valeur n'est pas transitive: il faut toujours
|
||||||
# recharger explicitement tous les modules désirés
|
# recharger explicitement tous les modules désirés
|
||||||
NUCORE_FORCE_RELOAD=
|
NULIB_FORCE_RELOAD=
|
||||||
|
|
||||||
function nucore__define_functions() {
|
function nulib__define_functions() {
|
||||||
function nucore_check_loaded() {
|
function nulib_check_loaded() {
|
||||||
local module
|
local module
|
||||||
for module in "${NUCORE_LOADED_MODULES[@]}"; do
|
for module in "${NULIB_LOADED_MODULES[@]}"; do
|
||||||
[ "$module" == "$1" ] && return 0
|
[ "$module" == "$1" ] && return 0
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
function module:() {
|
function module:() {
|
||||||
NUCORE_MODULE="$1"
|
NULIB_MODULE="$1"
|
||||||
if ! nucore_check_loaded "$1"; then
|
if ! nulib_check_loaded "$1"; then
|
||||||
NUCORE_LOADED_MODULES+=("$1")
|
NULIB_LOADED_MODULES+=("$1")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function function:() {
|
function function:() {
|
||||||
|
@ -96,64 +96,64 @@ function nucore__define_functions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nucore__require:() {
|
function nulib__require:() {
|
||||||
local nr__module nr__nucoredir nr__found
|
local nr__module nr__nulibdir nr__found
|
||||||
[ $# -gt 0 ] || set DEFAULTS
|
[ $# -gt 0 ] || set DEFAULTS
|
||||||
|
|
||||||
# sauvegarder valeurs globales
|
# sauvegarder valeurs globales
|
||||||
local nr__orig_module="$NUCORE_MODULE"
|
local nr__orig_module="$NULIB_MODULE"
|
||||||
NUCORE_MODULE=
|
NULIB_MODULE=
|
||||||
|
|
||||||
# garder une copie de la valeur originale et casser la transitivité
|
# garder une copie de la valeur originale et casser la transitivité
|
||||||
local nr__force_reload="$NUCORE_FORCE_RELOAD"
|
local nr__force_reload="$NULIB_FORCE_RELOAD"
|
||||||
local NUCORE_FORCE_RELOAD
|
local NULIB_FORCE_RELOAD
|
||||||
|
|
||||||
for nr__module in "$@"; do
|
for nr__module in "$@"; do
|
||||||
nr__found=
|
nr__found=
|
||||||
for nr__nucoredir in "${NUCOREDIRS[@]}"; do
|
for nr__nulibdir in "${NULIBDIRS[@]}"; do
|
||||||
if [ -f "$nr__nucoredir/$nr__module.sh" ]; then
|
if [ -f "$nr__nulibdir/$nr__module.sh" ]; then
|
||||||
nr__found=1
|
nr__found=1
|
||||||
if [ -n "$nr__force_reload" ] || ! nucore_check_loaded "$nr__module"; then
|
if [ -n "$nr__force_reload" ] || ! nulib_check_loaded "$nr__module"; then
|
||||||
NUCORE_LOADED_MODULES+=("$nr__module")
|
NULIB_LOADED_MODULES+=("$nr__module")
|
||||||
source "$nr__nucoredir/$nr__module.sh" || die
|
source "$nr__nulibdir/$nr__module.sh" || die
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -z "$nr__found" -a "$nr__module" == DEFAULTS ]; then
|
if [ -z "$nr__found" -a "$nr__module" == DEFAULTS ]; then
|
||||||
for nr__module in "${NUCORE_DEFAULT_MODULES[@]}"; do
|
for nr__module in "${NULIB_DEFAULT_MODULES[@]}"; do
|
||||||
if [ -f "$nr__nucoredir/$nr__module.sh" ]; then
|
if [ -f "$nr__nulibdir/$nr__module.sh" ]; then
|
||||||
nr__found=1
|
nr__found=1
|
||||||
if [ -n "$nr__force_reload" ] || ! nucore_check_loaded "$nr__module"; then
|
if [ -n "$nr__force_reload" ] || ! nulib_check_loaded "$nr__module"; then
|
||||||
NUCORE_LOADED_MODULES+=("$nr__module")
|
NULIB_LOADED_MODULES+=("$nr__module")
|
||||||
source "$nr__nucoredir/$nr__module.sh" || die
|
source "$nr__nulibdir/$nr__module.sh" || die
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
[ -n "$nr__found" ] || die "nucore: unable to find module $nr__module in (${NUCOREDIRS[*]})"
|
[ -n "$nr__found" ] || die "nulib: unable to find module $nr__module in (${NULIBDIRS[*]})"
|
||||||
done
|
done
|
||||||
|
|
||||||
# restaurer valeurs globales
|
# restaurer valeurs globales
|
||||||
NUCORE_MODULE="$nr__orig_module"
|
NULIB_MODULE="$nr__orig_module"
|
||||||
}
|
}
|
||||||
|
|
||||||
function require:() {
|
function require:() {
|
||||||
[ -z "$NUCORE_NO_DISABLE_SET_X" ] && [[ $- == *x* ]] && { set +x; local NUCORE_REQUIRE_SET_X=1; }; if [ -n "$NUCORE_REQUIRE_SET_X" ]; then [ -n "$NUCORE_REQUIRE_SET_X_RL1" ] || local NUCORE_REQUIRE_SET_X_RL1; local NUCORE_REQUIRE_SET_X_RL2=$RANDOM; [ -n "$NUCORE_REQUIRE_SET_X_RL1" ] || NUCORE_REQUIRE_SET_X_RL1=$NUCORE_REQUIRE_SET_X_RL2; fi # désactiver set -x de manière réentrante
|
[ -z "$NULIB_NO_DISABLE_SET_X" ] && [[ $- == *x* ]] && { set +x; local NULIB_REQUIRE_SET_X=1; }; if [ -n "$NULIB_REQUIRE_SET_X" ]; then [ -n "$NULIB_REQUIRE_SET_X_RL1" ] || local NULIB_REQUIRE_SET_X_RL1; local NULIB_REQUIRE_SET_X_RL2=$RANDOM; [ -n "$NULIB_REQUIRE_SET_X_RL1" ] || NULIB_REQUIRE_SET_X_RL1=$NULIB_REQUIRE_SET_X_RL2; fi # désactiver set -x de manière réentrante
|
||||||
nucore__define_functions
|
nulib__define_functions
|
||||||
nucore__require: "$@"
|
nulib__require: "$@"
|
||||||
[ -n "$NUCORE_REQUIRE_SET_X" -a "$NUCORE_REQUIRE_SET_X_RL1" == "$NUCORE_REQUIRE_SET_X_RL2" ] && set -x
|
[ -n "$NULIB_REQUIRE_SET_X" -a "$NULIB_REQUIRE_SET_X_RL1" == "$NULIB_REQUIRE_SET_X_RL2" ] && set -x
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
## Autres modules
|
## Autres modules
|
||||||
[ -d "$NUCOREDIR/awk/src" ] && inspath "$NUCOREDIR/awk/src" AWKPATH; export AWKPATH
|
[ -d "$NULIBDIR/awk/src" ] && inspath "$NULIBDIR/awk/src" AWKPATH; export AWKPATH
|
||||||
[ -d "$NUCOREDIR/python3/src" ] && inspath "$NUCOREDIR/python3/src" PYTHONPATH; export PYTHONPATH
|
[ -d "$NULIBDIR/python3/src" ] && inspath "$NULIBDIR/python3/src" PYTHONPATH; export PYTHONPATH
|
||||||
|
|
||||||
## Auto import DEFAULTS
|
## Auto import DEFAULTS
|
||||||
nucore__define_functions
|
nulib__define_functions
|
||||||
if [ -n "$NUCORE_SOURCED" -a -z "$NUCORE_NO_IMPORT_DEFAULTS" ]; then
|
if [ -n "$NULIB_SOURCED" -a -z "$NULIB_NO_IMPORT_DEFAULTS" ]; then
|
||||||
require: DEFAULTS
|
require: DEFAULTS
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue