common.subr (244994) | common.subr (245052) |
---|---|
1if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1 2# 3# Copyright (c) 2012 Ron McDowell 4# Copyright (c) 2012 Devin Teske 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# | 1if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1 2# 3# Copyright (c) 2012 Ron McDowell 4# Copyright (c) 2012 Devin Teske 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# |
28# $FreeBSD: head/usr.sbin/bsdconfig/share/common.subr 244994 2013-01-03 15:48:00Z dteske $ | 28# $FreeBSD: head/usr.sbin/bsdconfig/share/common.subr 245052 2013-01-05 02:08:47Z dteske $ |
29# 30############################################################ CONFIGURATION 31 32# 33# Default file descriptors to link to stdout/stderr for passthru allowing 34# redirection within a sub-shell to bypass directly to the terminal. 35# 36: ${TERMINAL_STDOUT_PASSTHRU:=3}} --- 72 unchanged lines hidden (view full) --- 109# A wrapper to the `type' built-in. Returns true if argument is a valid shell 110# built-in, keyword, or externally-tracked binary, otherwise false. 111# 112f_have() 113{ 114 f_quietly type "$@" 115} 116 | 29# 30############################################################ CONFIGURATION 31 32# 33# Default file descriptors to link to stdout/stderr for passthru allowing 34# redirection within a sub-shell to bypass directly to the terminal. 35# 36: ${TERMINAL_STDOUT_PASSTHRU:=3}} --- 72 unchanged lines hidden (view full) --- 109# A wrapper to the `type' built-in. Returns true if argument is a valid shell 110# built-in, keyword, or externally-tracked binary, otherwise false. 111# 112f_have() 113{ 114 f_quietly type "$@" 115} 116 |
117# f_getvar $var_to_get [$var_to_set] 118# 119# Utility function designed to go along with the already-builtin setvar. 120# Allows clean variable name indirection without forking or sub-shells. 121# 122# Returns error status if the requested variable ($var_to_get) is not set. 123# 124# If $var_to_set is missing or NULL, the value of $var_to_get is printed to 125# standard output for capturing in a sub-shell (which is less-recommended 126# because of performance degredation; for example, when called in a loop). 127# 128f_getvar() 129{ 130 local var_to_get="$1" var_to_set="$2" 131 [ "$var_to_set" ] || local value 132 eval ${var_to_set:-value}=\"\${$var_to_get}\" 133 eval [ \"\${$var_to_get+set}\" ] 134 local retval=$? 135 eval f_dprintf '"f_getvar: var=[%s] value=[%s] r=%u"' \ 136 \"\$var_to_get\" \"\$${var_to_set:-value}\" \$retval 137 [ "$var_to_set" ] || { [ "$value" ] && echo "$value"; } 138 return $retval 139} 140 |
|
117# f_die [ $status [ $fmt [ $opts ... ]]] 118# 119# Abruptly terminate due to an error optionally displaying a message in a 120# dialog box using printf(1) syntax. 121# 122f_die() 123{ 124 local status=$FAILURE --- 433 unchanged lines hidden --- | 141# f_die [ $status [ $fmt [ $opts ... ]]] 142# 143# Abruptly terminate due to an error optionally displaying a message in a 144# dialog box using printf(1) syntax. 145# 146f_die() 147{ 148 local status=$FAILURE --- 433 unchanged lines hidden --- |