Skip to content

Commit aacc78f

Browse files
committed
Allow child bashio processes to access the parent LOG_FD variable
1 parent d9f9ee5 commit aacc78f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/log.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
# to be included in add-on scripts to reduce code duplication across add-ons.
88
# ==============================================================================
99

10-
# Unless $LOG_FD is already set to a valid fd
11-
if ! [[ "${LOG_FD-}" =~ ^[0-9]+$ ]] || ! { : >&"${LOG_FD-2}"; } 2>/dev/null; then
10+
# Unless $LOG_FD is already set to a valid fd.
11+
if ! [[ "${LOG_FD:-}" =~ ^[0-9]+$ ]] || ! { : >&"${LOG_FD:-}"; } 2>/dev/null; then
1212
# Preserve the original STDOUT on a free fd (stored in $LOG_FD) so that we can
13-
# log to it without interfering with the STDOUT of subshells whose output we
14-
# want to capture for other purposes.
13+
# log to it without interfering with the STDOUT of subshells or child processes
14+
# whose output we want to capture for other purposes.
1515
exec {LOG_FD}>&1
1616
fi
17+
# Export LOG_FD for use by child bashio processes.
18+
# This is done outside of the above conditional to ensure that LOG_FD is also
19+
# exported if it was already set without using `export`.
20+
export LOG_FD
1721

1822
# ------------------------------------------------------------------------------
1923
# Log a message to output.

0 commit comments

Comments
 (0)