diff --git a/lib/ulib/base.array b/lib/ulib/base.array index 5dadff4..3940090 100644 --- a/lib/ulib/base.array +++ b/lib/ulib/base.array @@ -3,10 +3,3 @@ ##@cooked nocomments uprovide base.array urequire base.core - -function is_array() { -# tester si la variable $1 est un tableau - local -a arrays - eval "arrays=($(declare -p -a | while read dummy dummy var; do echo ${var%%=*}; done))" - array_contains arrays "$1" -} diff --git a/lib/ulib/base.core b/lib/ulib/base.core index 9a540f5..d3c4484 100644 --- a/lib/ulib/base.core +++ b/lib/ulib/base.core @@ -377,6 +377,16 @@ function err2out() { "$@" 2>&1 } +function is_defined() { +# tester si la variable $1 est définie + [ -n "$(declare -p "$1" 2>/dev/null)" ] +} +function is_array() { +# tester si la variable $1 est un tableau + case "$(declare -p "$1" 2>/dev/null)" in declare\ -a*) return 0;; esac + return 1 +} + # cf http://www.fvue.nl/wiki/Bash:_Passing_variables_by_reference function upvar() { # Assign variable one scope above the caller