From nobody Tue Oct 22 18:08:59 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XY0YR5KTJz5VhJg; Tue, 22 Oct 2024 18:08:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XY0YR4M73z4gdq; Tue, 22 Oct 2024 18:08:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729620539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fkPVLIWol6YQr8jH0Ws6cNmbcdh6EZefJhJk3gs3Shc=; b=wJgBZhMtXUNj7FCzbMI2ZScyDpseiBc1eeqxoFVy0DR4woY1srC8hfVEWzWY8pCaZEnXcp Bs1BYFqDUq+7MAks4gBOZ5wTNQ6cOJiRrss4TNv5qezlnWNdbToc+6eW7CpR6I67/s2j5d ioyVOwJsaV77A5eaXNXdIyV5DpTV/3OnC0WvxeNd2mWOGtesmDGSy0bhbXywV3klAQb0dc kJZ7V9vj25RuQj2LXOZPkwEl+CCkZ7X6liUSaxzddQGRop5AqnUUa9b/ki2VaPpru2+Yb1 XESce2RZpUC316XOTaQD7A0uR5B8UljnxzEGO/qDQDm1LxDgyxL/ab3TCO+zPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729620539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fkPVLIWol6YQr8jH0Ws6cNmbcdh6EZefJhJk3gs3Shc=; b=P130o1W3z1Jt3mxZITRricBPNNgPzpVcCbYwwEXD2Hh/Rp4ZZXiVIOd7xbIZCOkKjq+N3b 5b6mcEuGcenCBzy2DNbhS9YPqP6TMdW7Aj5wDN/K4CtJATFn9F4SlpDGpllqGQAt3SNcoP 8AJ8ZXl1g31+POUg6eoIL6/o/4MKiV61F/gyMzeGQ/MppPGZBKrsrdcLbaPu/ci7kdtqF6 EkFOP0SwmAVy6L0Jon0NYAdE7Fz8A/loh32ou3y38Tm8/6LzIBe/UGZF/vDQuL0w1VSFZq Zv4cDUpVRhGsIk22CgGJWxQKCQ4WW0aD0qISFg3X17uGDaetaIFoJ5TuMZrlew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729620539; a=rsa-sha256; cv=none; b=bC3SPrJR0GFNEpU+rY/3rAf+3pNHQUyXrPiBEuj6L2ewRxPwFUek0b5yjcgm+QC5RLUAx1 hEo7RLH3cvXL7aJ8fMmb0Q9aRjtznpGaZyo/TVyJLiUH90De194gljYUBJAROtKYR83jXi Y/+PqvhJsBaab/v27zVWLzm3p0cJ33SzVvEB7Ev0QJm1NUqnd1oe7dhvYhk/Ggd3yFyb56 ExFrDvj6ObbrfkjIvR5vOGiXZVoXI/pakpnDCXzk1KJQXday0fOXJJ7MP0cb5Y0q/jl+Cy kn9TIjAEJw8qXrwR35FXG7CnXEdkOk1mlmgTom3QTwjwTFUP/LFaC4I844RyAw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XY0YR3yCRzP7V; Tue, 22 Oct 2024 18:08:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49MI8xA7050980; Tue, 22 Oct 2024 18:08:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49MI8xj2050978; Tue, 22 Oct 2024 18:08:59 GMT (envelope-from git) Date: Tue, 22 Oct 2024 18:08:59 GMT Message-Id: <202410221808.49MI8xj2050978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: 02653835cd6f - main - debug.sh add DebugAdd List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 02653835cd6f1dc4a34f08d3b744fbb7c4b1ecdb Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=02653835cd6f1dc4a34f08d3b744fbb7c4b1ecdb commit 02653835cd6f1dc4a34f08d3b744fbb7c4b1ecdb Author: Simon J. Gerraty AuthorDate: 2024-10-22 18:07:37 +0000 Commit: Simon J. Gerraty 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 # 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