From nobody Tue Dec 31 18:49:22 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 4YN27k2mSNz5jsYD; Tue, 31 Dec 2024 18:49:22 +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 4YN27k25fKz4mrR; Tue, 31 Dec 2024 18:49:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735670962; 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=wFo35ZLkoXyhSCu33LAT8/klJVwTO7R/cC9ypPIaH04=; b=dTFfLV9Gdo6y+Z3yt4Jpkgj/38g9AlECki8zWS+AjHslWDTrJbMeal55ATZccNF/Q8sPNx p6mAPcG/OUV9AKMxBrUO1AG+viucxvPstl7lblC9i66VPiS/zBmoXeSP/6eagW2KkmyETg tx5iUtI4Ne2mLNymgPw3OzeQVeM8GNTKE9TBIqxH8M9wAN0/i/AZTKOa5yqZXlLiWHagw5 O5WjQPsBcWfoBM7wOed7ICSY7kmCiEGNCucQat5sAjCoMn1fhnx2DoN2zKR+N1pt8uNgRq uJ92MyrBerVLzCjGx2YEUFI4tn6HgGUNU7BM6tLTnZuxKNOXTNSomL8AFK+UrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735670962; 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=wFo35ZLkoXyhSCu33LAT8/klJVwTO7R/cC9ypPIaH04=; b=dGko44uOwoc1a1zBgm9cWkkMa7QMTZwUr8//6g7JyJVRyEpH6NLrTOIs/0QtGDvhZtpqsX 8XeVTFEf1e/QdEQAxydp2KI9CZFxTuulltKPjNVyII9iuo2XKv6DCfu0zmXq21+ygX7Uep HBHlj9rdA5sGUlZilh2ZycqZ12edvVX5diYJ26lAGR/zqWXF4DUb2Qkde3+BMoa0F3/AKH lzI/S8HtMGVBHOVxGOrEfCiwijXFNbp+eXqt08pJiSvCoQNcQQ9Xfo/uJOZEwrddNCMgvM f/pfuJXqJbyAOQMfHsClV3cidcvIZuDJu3OledIWH6A5WqfFja0EEpPcP5gmiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735670962; a=rsa-sha256; cv=none; b=u8IyqGBYAL1CMnjl4EsaiKdWyitBXtzO++qgXC/NcfDSb+CavFrmn56aj4jrau40kfxlnq AIYLMxmkb0Fv+KEerJR9mIAWDcLAY0IneV3w2hkZTWTsz0/2KztbNjud725FYl1lvNm6C2 qSGqw39QS+pvUHyITSIeCBz+44Da+Eqr0D68ME8DdWRhaICMtrVWWub4sPW7zsGc2IJV+w 923VaEzxOQlIqy9L+poBVTb3xmTBSsSyXpWSaFd1dDNQQkil5i4JzLTqOW8evEZ7uCy5rD n/6JnBCphi4izOgBTueJ+8W1lUxku3u6CdmzGUG6ciziEG7GgOQrSWAOyhkfow== 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 4YN27k1YSyzrgH; Tue, 31 Dec 2024 18:49:22 +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 4BVInMFC005481; Tue, 31 Dec 2024 18:49:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BVInMtG005478; Tue, 31 Dec 2024 18:49:22 GMT (envelope-from git) Date: Tue, 31 Dec 2024 18:49:22 GMT Message-Id: <202412311849.4BVInMtG005478@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: 203027b2d5dc - main - Update libexec/rc/debug.sh and hooks.sh 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: 203027b2d5dc89fec3a0a7eee195a11cb394587f Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=203027b2d5dc89fec3a0a7eee195a11cb394587f commit 203027b2d5dc89fec3a0a7eee195a11cb394587f Author: Simon J. Gerraty AuthorDate: 2024-12-31 18:47:06 +0000 Commit: Simon J. Gerraty CommitDate: 2024-12-31 18:47:06 +0000 Update libexec/rc/debug.sh and hooks.sh Use local_works() to test if 'local' actually works for current shell. --- libexec/rc/debug.sh | 46 ++++++++++++++++++++++++++++++++-------------- libexec/rc/hooks.sh | 37 +++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/libexec/rc/debug.sh b/libexec/rc/debug.sh index db9ed8c94b6c..b379297a4183 100755 --- a/libexec/rc/debug.sh +++ b/libexec/rc/debug.sh @@ -83,7 +83,7 @@ # Simon J. Gerraty # RCSid: -# $Id: debug.sh,v 1.42 2024/10/30 18:23:19 sjg Exp $ +# $Id: debug.sh,v 1.46 2024/12/13 03:55:52 sjg Exp $ # # @(#) Copyright (c) 1994-2024 Simon J. Gerraty # @@ -107,27 +107,45 @@ DEBUG_DO=: DEBUG_SKIP= export DEBUGGING DEBUG_DO DEBUG_SKIP -case "$isPOSIX_SHELL,$local" in -:,:|:,local|false,:) ;; # sane -*) # this is the bulk of isposix-shell.sh +# have is handy +if test -z "$_HAVE_SH"; then + _HAVE_SH=: + + ## + # have that does not rely on return code of type + # + have() { + case `(type "$1") 2>&1` in + *" found") return 1;; + esac + return 0 + } +fi + +# does local *actually* work? +local_works() { + local _fu +} + +if local_works > /dev/null 2>&1; then + _local=local +else + _local=: +fi +# for backwards compatability +local=$_local + +if test -z "$isPOSIX_SHELL"; then if (echo ${PATH%:*}) > /dev/null 2>&1; then # true should be a builtin, : certainly is isPOSIX_SHELL=: - # you need to eval $local var - local=local - : KSH_VERSION=$KSH_VERSION - case "$KSH_VERSION" in - Version*) local=: ;; # broken - esac else isPOSIX_SHELL=false - local=: false() { return 1 } fi - ;; -esac +fi is_posix_shell() { $isPOSIX_SHELL @@ -142,7 +160,7 @@ is_posix_shell() { # a suffix of :debug_add:tag we will add tag to DEBUG_SH # _debugAdd() { - eval $local tag + eval $_local tag for tag in `IFS=,; echo $DEBUG_SH` do diff --git a/libexec/rc/hooks.sh b/libexec/rc/hooks.sh index 3b0c50f10191..7c478fbeda15 100755 --- a/libexec/rc/hooks.sh +++ b/libexec/rc/hooks.sh @@ -50,7 +50,7 @@ # # RCSid: -# $Id: hooks.sh,v 1.21 2024/09/06 16:53:45 sjg Exp $ +# $Id: hooks.sh,v 1.24 2024/12/13 03:55:52 sjg Exp $ # # @(#)Copyright (c) 2000-2024 Simon J. Gerraty # @@ -64,18 +64,19 @@ # avoid multiple inclusion _HOOKS_SH=: -# We want to use local if we can -# if isposix-shell.sh has been sourced isPOSIX_SHELL will be set -# as will local -case "$local" in -local|:) ;; -*) if (echo ${PATH%:*}) > /dev/null 2>&1; then - local=local - else - local=: - fi - ;; -esac +# does local *actually* work? +local_works() { + local _fu +} + +if local_works > /dev/null 2>&1; then + _local=local +else + _local=: +fi +# for backwards compatability +local=$_local + ## # hooks_add_all list func ... @@ -83,7 +84,7 @@ esac # add "func"s to "list" regardless # hooks_add_all() { - eval $local __h + eval $_local __h __h=$1; shift case "$1" in --first) @@ -100,7 +101,7 @@ hooks_add_all() { # add "func"s to "list" if not already there # hooks_add_once() { - eval $local __h __hh __first + eval $_local __h __hh __first __h=$1; shift case "$1" in --first) shift; __first=:;; @@ -154,7 +155,7 @@ hooks_add() { # return $list # hooks_get() { - eval $local __h __h2 e __l + eval $_local __h __h2 e __l case "$1" in --lifo) __l=LIFO; shift;; esac @@ -178,7 +179,7 @@ hooks_get() { # is func in $list ? # hooks_has() { - eval $local __h + eval $_local __h eval "__h=\$$1" case " $__h " in *" $1 "*) return 0;; @@ -193,7 +194,7 @@ hooks_has() { # Without '--all'; if any return non-zero return that immediately # hooks_run() { - eval $local __a e __h __hl __h2 __l + eval $_local __a e __h __hl __h2 __l __a=return __l=