déplacement de is_defined() et is_array() dans base.core
This commit is contained in:
parent
d735b7b695
commit
4a4094c493
|
@ -3,10 +3,3 @@
|
||||||
##@cooked nocomments
|
##@cooked nocomments
|
||||||
uprovide base.array
|
uprovide base.array
|
||||||
urequire base.core
|
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"
|
|
||||||
}
|
|
||||||
|
|
|
@ -377,6 +377,16 @@ function err2out() {
|
||||||
"$@" 2>&1
|
"$@" 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
|
# cf http://www.fvue.nl/wiki/Bash:_Passing_variables_by_reference
|
||||||
function upvar() {
|
function upvar() {
|
||||||
# Assign variable one scope above the caller
|
# Assign variable one scope above the caller
|
||||||
|
|
Loading…
Reference in New Issue