-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Problem
I'm attempting to use logging.sh for my scripts.
Sourcing base.sh then logging.sh fails due to trap statements, and issues with the tty checks.
Sourcing in the reverse order logging.sh then base.sh fails, as REQUIRES_CMDS is set in base.sh.
++++ set -o nounset
++++ set -o errexit
++++ set -o pipefail
++++ set -o errtrace
++++ shopt -s dotglob
++++ shopt -s inherit_errexit
++++ IFS='
'
++++ trap 'log_quit SIGINT' SIGINT
++++ trap 'log_quit SIGPIPE' SIGPIPE
++++ trap 'log_quit SIGQUIT' SIGQUIT
++++ trap 'log_quit SIGTSTP' SIGTSTP
++++ trap 'log_quit TIMEOUT' SIGALRM
++++ trap 'log_quit $? "${BASH_SOURCE//$PWD/.}:${LINENO} ${FUNCNAME:-}($(IFS=" "; echo "$*"))"' ERR
++++++ dirname hack/opt/bash-utils/util/base.sh
+++++ cd hack/opt/bash-utils/util
+++++ cd ..
+++++ pwd
++++ SCRIPTS_DIR=/home/steven/src/github/s-fairchild/titan/hack/opt/bash-utils
++++ ROOT_PID=218993
++++ PARENT_PID=171765
++++ [[ ! -t 0 ]]
++++++ IFS=' '
++++++ echo deploy/butane/overlays/prod/main.bu
+++++ log_quit 1 'hack/opt/bash-utils/util/base.sh:28 (deploy/butane/overlays/prod/main.bu)'
hack/opt/bash-utils/util/base.sh: line 28: log_quit: command not foundQuestions
- Can you provide some documentation as to how these files are intended to be sourced?
- What is the purpose of this?
- test exit code
0is causing traps to be triggered. Which intern fail themselves, aslog_quitis unset.# Script output with set -xtrace ++++ [[ ! -t 0 ]] ++++++ IFS=' ' ++++++ echo deploy/butane/overlays/prod/main.bu +++++ log_quit 1 'hack/opt/bash-utils/util/base.sh:28 (deploy/butane/overlays/prod/main.bu)' hack/opt/bash-utils/util/base.sh: line 28: log_quit: command not **found**
- Is
IS_TTYcurrently used? Or for future use? - What is the intended purpose here? Test returns exit code 0 within the shell script. There is no difference when I do the same in an interactive terminal.
steven@r10:~$ for i in {0..2}; do [[ ! -t $i ]]; echo -n $?; done 111 steven@r10:~$ tty /dev/pts/0 steven@r10:~$ ls /dev/pts 0 1 2 3 4 5 6 7 8 9 ptmx
- test exit code
- If traps are triggered, they fail, as
logging.shcannot be sourced beforebase.sh. log_quit is unset.
Additional Notes
When I remove the tty tests everything works as expected.
I am planning on creating a fork to remove this, but I hate to have a fork just for this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels