Deleted Added
full compact
common.subr (250317) common.subr (250633)
1if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1
2#
3# Copyright (c) 2012 Ron McDowell
4# Copyright (c) 2012-2013 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-2013 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 250317 2013-05-07 03:57:45Z dteske $
28# $FreeBSD: head/usr.sbin/bsdconfig/share/common.subr 250633 2013-05-14 03:21:13Z 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}}

--- 25 unchanged lines hidden (view full) ---

62export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
63export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
64
65#
66# Default behavior is to call f_debug_init() automatically when loaded.
67#
68: ${DEBUG_SELF_INITIALIZE=1}
69
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}}

--- 25 unchanged lines hidden (view full) ---

62export UNAME_P="$(uname -p)" # Processor Architecture (i.e. i386)
63export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE)
64
65#
66# Default behavior is to call f_debug_init() automatically when loaded.
67#
68: ${DEBUG_SELF_INITIALIZE=1}
69
70#
71# Define standard optstring arguments that should be supported by all programs
72# using this include (unless DEBUG_SELF_INITIALIZE is set to NULL to prevent
73# f_debug_init() from autamatically processing "$@" for the below arguments):
74#
75# d Sets $debug to 1
76# D: Sets $debugFile to $OPTARG
77#
78GETOPTS_STDARGS="dD:"
79
70############################################################ FUNCTIONS
71
72# f_dprintf $fmt [ $opts ... ]
73#
74# Sensible debug function. Override in ~/.bsdconfigrc if desired.
75# See /usr/share/examples/bsdconfig/bsdconfigrc for example.
76#
77# If $debug is set and non-NULL, prints DEBUG info using printf(1) syntax:

--- 19 unchanged lines hidden (view full) ---

97#
98f_debug_init()
99{
100 #
101 # Process stored command-line arguments
102 #
103 set -- $ARGV
104 local OPTIND
80############################################################ FUNCTIONS
81
82# f_dprintf $fmt [ $opts ... ]
83#
84# Sensible debug function. Override in ~/.bsdconfigrc if desired.
85# See /usr/share/examples/bsdconfig/bsdconfigrc for example.
86#
87# If $debug is set and non-NULL, prints DEBUG info using printf(1) syntax:

--- 19 unchanged lines hidden (view full) ---

107#
108f_debug_init()
109{
110 #
111 # Process stored command-line arguments
112 #
113 set -- $ARGV
114 local OPTIND
105 while getopts dD: flag > /dev/null; do
115 f_dprintf "f_debug_init: ARGV=[%s] GETOPTS_STDARGS=[%s]" \
116 "$ARGV" "$GETOPTS_STDARGS"
117 while getopts "$GETOPTS_STDARGS" flag > /dev/null; do
106 case "$flag" in
107 d) debug=1;;
108 D) debugFile="$OPTARG";;
109 \?) continue;;
110 esac
111 done
112 shift $(( $OPTIND - 1 ))
118 case "$flag" in
119 d) debug=1;;
120 D) debugFile="$OPTARG";;
121 \?) continue;;
122 esac
123 done
124 shift $(( $OPTIND - 1 ))
125 f_dprintf "f_debug_init: debug=[%s] debugFile=[%s]" \
126 "$debug" "$debugFile"
113
114 #
115 # Automagically enable debugging if debugFile is set (and non-NULL)
116 #
117 [ "$debugFile" ] && { [ "${debug+set}" ] || debug=1; }
118
119 #
120 # Make debugging persistant if set

--- 582 unchanged lines hidden ---
127
128 #
129 # Automagically enable debugging if debugFile is set (and non-NULL)
130 #
131 [ "$debugFile" ] && { [ "${debug+set}" ] || debug=1; }
132
133 #
134 # Make debugging persistant if set

--- 582 unchanged lines hidden ---