From 74c839cd6bb5582e30c4412dea34620be4c0c844 Mon Sep 17 00:00:00 2001 From: clsr Date: Sun, 23 Apr 2017 22:02:55 +0200 Subject: Let bash find and assign file descriptors for IRC socket and logging --- modules/log.bash | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/log.bash b/modules/log.bash index e9fc665..cd4e038 100644 --- a/modules/log.bash +++ b/modules/log.bash @@ -16,12 +16,12 @@ fi if [[ -n ${LOG_IRC:-} ]]; then if [[ ${LOG_SHOW_IRC:-0} -ne 0 ]]; then - exec 14> >(tee -a -- "$LOG_IRC") + exec {log_fd}> >(tee -a -- "$LOG_IRC") else - exec 14>>"$LOG_IRC" + exec {log_fd}>>"$LOG_IRC" fi elif [[ ${LOG_SHOW_IRC:-0} -ne 0 ]]; then - exec 14>&1 + exec {log_fd}>&1 fi if [[ -n ${LOG_ERR:-} ]]; then @@ -31,12 +31,12 @@ fi # log received messages on_readmsg() { # args: $1 - raw message, $2 - source, $3 - command, $4... - args - printf "%s <<< %s\n" "$(log_timestamp)" "$1" >&14 + printf "%s <<< %s\n" "$(log_timestamp)" "$1" >&$log_fd } # log sent messages on_sendmsg() { # args: $1 - raw message, $2 - command, $3... - args - printf "%s >>> %s\n" "$(log_timestamp)" "$1" >&14 + printf "%s >>> %s\n" "$(log_timestamp)" "$1" >&$log_fd } log_timestamp() { -- cgit