git: a797702be077 - main - rc.subr set dot_dir and dot_file in dot

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Thu, 30 Oct 2025 18:09:39 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=a797702be077c4671e3d437d6b9ffd37f2e86277

commit a797702be077c4671e3d437d6b9ffd37f2e86277
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2025-10-30 18:09:13 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2025-10-30 18:09:13 +0000

    rc.subr set dot_dir and dot_file in dot
    
    Files read by '.' cannot workout for themselves where they are
    or what they are called, so set dot_dir and dot_file to pass
    this information to them.
    
    Reviewed by:    obrien, stevek
    Differential Revision:  https://reviews.freebsd.org/D53476
---
 libexec/rc/rc.subr | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 8317ff5c0922..e4ad14f582d6 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -121,11 +121,22 @@ dotted=
 dot()
 {
 	local f verify
+	local dot_dir dot_file
 
 	o_verify_set off verify
 	for f in "$@"; do
 		if [ -f $f -a -s $f ]; then
 			dotted="$dotted $f"
+			case $f in
+			*/*)
+				dot_dir=${f%/*}
+				dot_file=${f##*/}
+				;;
+			*)
+				dot_dir=.
+				dot_file=$f
+				;;
+			esac
 			. $f
 		fi
 	done
@@ -152,8 +163,7 @@ vdot()
 	for f in "$@"; do
 		[ -f $f -a -s $f ] || continue
 		if is_verified $f 2> /dev/null; then
-			dotted="$dotted $f"
-			. $f
+			dot $f
 		else
 			rc=80	# EAUTH
 		fi