Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Suppress tracing of "set +x"



Dominik Vogt schreef op 05-02-16 om 10:09:
> I want only "some command" traced, not "RC=$?".

Try this:

exec 9>&2	# reserve file descriptor for tracing
trace() {
	local cmd=$(printf '%q ' "$@")
	printf '+ %s\n' "$cmd" 2>&9
	"$@"
}

trace some command

This will only work for simple commands, not for grammatical constructs
nor for anything with a function-local scope.

(The above code should also work on bash and ksh93.)

HTH,

- M.



Messages sorted by: Reverse Date, Date, Thread, Author