From 4a4094c4932e1d6e44cc815fd3a8b70a321721b4 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 1 Nov 2016 00:03:25 +0400 Subject: [PATCH] =?UTF-8?q?d=C3=A9placement=20de=20is=5Fdefined()=20et=20i?= =?UTF-8?q?s=5Farray()=20dans=20base.core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/base.array | 7 ------- lib/ulib/base.core | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) 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