déplacement de is_defined() et is_array() dans base.core

This commit is contained in:
Jephté Clain 2016-11-01 00:03:25 +04:00
parent d735b7b695
commit 4a4094c493
2 changed files with 10 additions and 7 deletions

View File

@ -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"
}

View File

@ -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