On Mon, Oct 27, 2025 at 04:45:27PM +0000, Simon Horman wrote:
log() {
- local prefix="$1"
- local redirect
- local prefix
- shift
- local redirect= if [[ ${VERBOSE} -eq 0 ]]; then redirect=/dev/null else redirect=/dev/stdout fi
- prefix="${LOG_PREFIX:-}"
- if [[ "$#" -eq 0 ]]; then
__log_stdin | tee -a "${LOG}" > ${redirect}
if [[ -n "${prefix}" ]]; thencat | awk -v prefix="${prefix}" '{printf "%s: %s\n", prefix, $0}'FIWIIW, I would drop cat from this line.
sgtm!
elsecat elsefi
__log_args "$@" | tee -a "${LOG}" > ${redirect}- fi
-}
-log_setup() {
- log "setup" "$@"
if [[ -n "${prefix}" ]]; thenecho "${prefix}: " "$@"elseecho "$@"fi- fi | tee -a "${LOG}" > ${redirect}
} log_host() {
- local testname=$1
- shift
- log "test:${testname}:host" "$@"
- LOG_PREFIX=host log $@
shellcheck suggests keeping the quoting of $@. This seems reasonable to me. Although in practice I don't think it will change the behaviour of this script.
Ah right, makes sense to me.
} log_host log_guest() {
- local testname=$1
- shift
- log "test:${testname}:guest" "$@"
- LOG_PREFIX=guest log $@
shellcheck also points out that log_guest is never passed arguments, so $@ can be dropped. If you prefer to keep it then, as per log_host, it seems reasonable for it to be quoted.
Quoting it sounds best to me, in keeping with log_host().
Thanks, Bobby