On Mon, Jan 21, 2019 at 11:59:30PM +0000, morganamilo wrote:
This helpers functions allows checking for the existence of a package variable without worrying if it is an array or not.
Seems reasonable, but where would this be used? Is this meant to consolidate existing cases of redundant code? Under what circumstances do we care about the variable existing without needing to know if it's an array or not?
Signed-off-by: morganamilo <morganamilo@gmail.com> --- scripts/libmakepkg/util/pkgbuild.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in index b29229a3..f9fc440b 100644 --- a/scripts/libmakepkg/util/pkgbuild.sh.in +++ b/scripts/libmakepkg/util/pkgbuild.sh.in @@ -98,6 +98,15 @@ extract_function_variable() { return $r }
+exists_function_variable() { + # $1: function name + # $2: variable name + + local funcname=$1 attr=$2 out + extract_function_variable "$funcname" "$attr" 0 out || \
The explicit line continuation isn't needed here -- || at the end of the line indicates a compound command that needs more tokens to be lexed before bash can complete the input.
+ extract_function_variable "$funcname" "$attr" 1 out +} + get_pkgbuild_attribute() { # $1: package name # $2: attribute name -- 2.20.1