Gentoo Archives: gentoo-dev

From: Donnie Berkholz <dberkholz@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Small review on function return codes and simplicity
Date: Tue, 31 Mar 2009 18:05:32
Message-Id: 20090331180530.GG13746@128-193-143-54
1 I noticed some eclass commits using java-pkg_func-exists() and it's a
2 lot more complicated than it needs to me. Perhaps not everybody knows
3 that bash generally gives a return status from functions of the last
4 command run in that function. So these two things are equivalent:
5
6 java-pkg_func-exists() {
7 if [[ -n "$(declare -f ${1})" ]]; then
8 return 0
9 else
10 return 1
11 fi
12 }
13
14
15 java-pkg_func-exists() {
16 [[ -n "$(declare -f ${1})" ]]
17 }
18
19
20 --
21 Thanks,
22 Donnie
23
24 Donnie Berkholz
25 Developer, Gentoo Linux
26 Blog: http://dberkholz.wordpress.com

Replies

Subject Author
Re: [gentoo-dev] Small review on function return codes and simplicity Ciaran McCreesh <ciaran.mccreesh@××××××××××.com>
Re: [gentoo-dev] Small review on function return codes and simplicity Alec Warner <antarus@g.o>