diff options
author | dteske <dteske@FreeBSD.org> | 2013-11-07 10:20:19 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-11-07 10:20:19 +0000 |
commit | 4bd843efbdbeff39eca31454eb34ecf56bd7388c (patch) | |
tree | 67bc8424d7483750ff30bd0bdb0b8ab03c968be6 | |
parent | 5a453bc0fc3724e5f3e2467ee3605a7d98632cad (diff) | |
download | FreeBSD-src-4bd843efbdbeff39eca31454eb34ecf56bd7388c.zip FreeBSD-src-4bd843efbdbeff39eca31454eb34ecf56bd7388c.tar.gz |
Add global DEBUG_INITIALIZE_FILE environment variable for controlling
whether the debugFile is truncated upon initialization (useful for when
children implicitly re-initialize debugging and you want children to
append to your existing debugFile).
-rw-r--r-- | usr.sbin/bsdconfig/share/common.subr | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr index 94f591a..3817ca8 100644 --- a/usr.sbin/bsdconfig/share/common.subr +++ b/usr.sbin/bsdconfig/share/common.subr @@ -68,6 +68,14 @@ export UNAME_R="$(uname -r)" # Release Level (i.e. X.Y-RELEASE) : ${DEBUG_SELF_INITIALIZE=1} # +# Default behavior of f_debug_init() is to truncate $debugFile (set to NULL to +# disable truncating the debug file when initializing). To get child processes +# to append to the same log file, export this variarable (with a NULL value) +# and also export debugFile with the desired value. +# +: ${DEBUG_INITIALIZE_FILE=1} + +# # Define standard optstring arguments that should be supported by all programs # using this include (unless DEBUG_SELF_INITIALIZE is set to NULL to prevent # f_debug_init() from autamatically processing "$@" for the below arguments): @@ -164,13 +172,13 @@ f_debug_init() [ "$debugFile" ] && export debugFile # - # Truncate the debug file upon. Note that we will trim a leading plus - # (`+') from the value of debugFile to support persistant meaning that - # f_dprintf() should print both to standard output and $debugFile - # (minus the leading plus, of course). + # Truncate debug file unless requested otherwise. Note that we will + # trim a leading plus (`+') from the value of debugFile to support + # persistant meaning that f_dprintf() should print both to standard + # output and $debugFile (minus the leading plus, of course). # local _debug_file="${debugFile#+}" - if [ "$_debug_file" ]; then + if [ "$_debug_file" -a "$DEBUG_INITIALIZE_FILE" ]; then if ( umask 022 && :> "$_debug_file" ); then f_dprintf "Successfully initialized debugFile \`%s'" \ "$_debug_file" |