On 16/09/15 06:17, Jan Alexander Steffens (heftig) wrote:
This reduces code duplication a bit. It also highlights how these options are checked.
Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> --- scripts/libmakepkg/util/option.sh | 22 ++++++++++++++++++++++ scripts/makepkg.sh.in | 8 ++++---- 2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/scripts/libmakepkg/util/option.sh b/scripts/libmakepkg/util/option.sh index 1b2d94d..1266e05 100644 --- a/scripts/libmakepkg/util/option.sh +++ b/scripts/libmakepkg/util/option.sh @@ -106,3 +106,25 @@ check_buildenv() { # not found return 127 } + +## +# Check if option is present in BUILDENV and not inverted in options +# +# usage : check_buildoption( $option, $expected_val ) +# return : 0 - matches expected +# 1 - does not match expected +# 127 - not found +## +check_buildoption() { + case "$2" in + y) # assert enabled + check_buildenv "$1" "y" && ! check_option "$1" "n" + return ;; + n) # assert disabled + check_buildenv "$1" "n" && ! check_option "$1" "y" + return ;; + esac + + # not found + return 127 +}
If you are adding a function for this, might as well fix the issue that the makepkg.conf OPTIONS array is check. Just check the "BUILDENV" and "options" arrays. A