From 1d17434b643c38bbd153694d8a84798b68282c0d Mon Sep 17 00:00:00 2001 From: Devin Teske Date: Tue, 7 May 2013 03:57:45 +0000 Subject: [PATCH] Add f_isset() utility subroutine for checking if a variable is set but in a more readable fashion. --- usr.sbin/bsdconfig/share/common.subr | 10 ++++++++++ usr.sbin/bsdconfig/startup/rcdelete | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr index 3989fadeb068..d92592c30924 100644 --- a/usr.sbin/bsdconfig/share/common.subr +++ b/usr.sbin/bsdconfig/share/common.subr @@ -195,6 +195,16 @@ f_getvar() return $__retval } +# f_isset $var +# +# Check if variable $var is set. Returns success if variable is set, otherwise +# returns failure. +# +f_isset() +{ + eval [ \"\${${1%%[$IFS]*}+set}\" ] +} + # f_die [ $status [ $fmt [ $opts ... ]]] # # Abruptly terminate due to an error optionally displaying a message in a diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete index b51f6cedcbd6..701877479797 100755 --- a/usr.sbin/bsdconfig/startup/rcdelete +++ b/usr.sbin/bsdconfig/startup/rcdelete @@ -388,7 +388,7 @@ while :; do var="${mtag# }" # Toggle the state-variable and loop back to menu - if eval [ \"\${_${var}_delete+set}\" ]; then + if f_isset _${var}_delete; then unset _${var}_delete else setvar _${var}_delete 1