git: 02653835cd6f - main - debug.sh add DebugAdd
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Oct 2024 18:08:59 UTC
The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=02653835cd6f1dc4a34f08d3b744fbb7c4b1ecdb commit 02653835cd6f1dc4a34f08d3b744fbb7c4b1ecdb Author: Simon J. Gerraty <sjg@FreeBSD.org> AuthorDate: 2024-10-22 18:07:37 +0000 Commit: Simon J. Gerraty <sjg@FreeBSD.org> CommitDate: 2024-10-22 18:07:37 +0000 debug.sh add DebugAdd Sometimes it is desirable while debugging one script for it to enable debugging of a child. We can do that with $DEBUG_DO DebugAdd tag to add tag to DEBUG_SH but only when we are already debugging. --- libexec/rc/debug.sh | 21 ++++++++++++++++++++- share/man/man8/debug.sh.8 | 11 ++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libexec/rc/debug.sh b/libexec/rc/debug.sh index eea8a011bc09..b098f0b359b5 100755 --- a/libexec/rc/debug.sh +++ b/libexec/rc/debug.sh @@ -9,6 +9,7 @@ # DebugOn [-eo] "tag" ... # DebugOff [-eo] [rc="rc"] "tag" ... # Debugging +# DebugAdd "tag" # DebugEcho ... # DebugLog ... # DebugShell "tag" ... @@ -39,6 +40,9 @@ # default of 0. Thus if DebugOff is the last operation in a # function, "rc" will be the return code of that function. # +# DebugAdd allows adding a "tag" to "DEBUG_SH" to influence +# later events, possibly in a child process. +# # DebugEcho is just shorthand for: #.nf # $DEBUG_DO echo "$@" @@ -74,7 +78,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: debug.sh,v 1.40 2024/09/09 20:06:00 sjg Exp $ +# $Id: debug.sh,v 1.41 2024/10/22 17:57:22 sjg Exp $ # # @(#) Copyright (c) 1994-2024 Simon J. Gerraty # @@ -167,6 +171,21 @@ _debugOff() { DEBUG_X= } +## +# DebugAdd tag +# +# Add tag to DEBUG_SH +# +DebugAdd() { + DEBUG_SH=${DEBUG_SH:+$DEBUG_SH,}$1 + export DEBUG_SH +} + +## +# DebugEcho message +# +# Output message if we are debugging +# DebugEcho() { $DEBUG_DO echo "$@" } diff --git a/share/man/man8/debug.sh.8 b/share/man/man8/debug.sh.8 index 2c137ff3fd42..77a1e06cc56a 100644 --- a/share/man/man8/debug.sh.8 +++ b/share/man/man8/debug.sh.8 @@ -12,7 +12,7 @@ .\" Please send copies of changes and bug-fixes to: .\" sjg@crufty.net .\" -.Dd January 31, 2024 +.Dd October 22, 2024 .Dt DEBUG.SH 8 .Os .Sh NAME @@ -30,6 +30,8 @@ .It .Ic Debugging .It +.Ic DebugAdd Ar tag +.It .Ic DebugEcho Op Ar message .It .Ic DebugLog Op Ar message @@ -110,6 +112,13 @@ It is useful for bounding complex debug actions, rather than using lots of .Ic $DEBUG_DO lines. +.It Ic DebugAdd Ar tag +Add +.Ar tag +to +.Va DEBUG_SH +to influence later output, +possibly in a child process. .It Ic DebugEcho is just shorthand for: .Bd -literal -offset indent