From nobody Sun Jun 15 14:41:12 2025 X-Original-To: dev-commits-src-all@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 4bKwmy1v6vz5Vky6; Sun, 15 Jun 2025 14:41:22 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mail01.stack.nl (scw01.stack.nl [51.15.111.152]) (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 (2048 bits) client-digest SHA256) (Client CN "ecc.stack.nl", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bKwmx3dCgz3gyM; Sun, 15 Jun 2025 14:41:21 +0000 (UTC) (envelope-from jilles@stack.nl) Authentication-Results: mx1.freebsd.org; none Received: from localhost (localhost.localdomain [127.0.0.1]) by mail01.stack.nl (Postfix) with ESMTP id C9FA562856; Sun, 15 Jun 2025 14:41:13 +0000 (UTC) Received: from mail01.stack.nl ([127.0.0.1]) by localhost (mail01.stack.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ORkC2K1GfFoJ; Sun, 15 Jun 2025 14:41:12 +0000 (UTC) Received: from blade.stack.nl (unknown [95.211.93.133]) by mail01.stack.nl (Postfix) with ESMTP id A601262854; Sun, 15 Jun 2025 14:41:12 +0000 (UTC) Received: by blade.stack.nl (Postfix, from userid 1677) id 7FDBD8005E; Sun, 15 Jun 2025 14:41:12 +0000 (UTC) Date: Sun, 15 Jun 2025 16:41:12 +0200 From: Jilles Tjoelker To: Hiroki Sato Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 7faddeb395b7 - main - rc: Fix scripts that need pathname expansion Message-ID: References: <202506142026.55EKQeGM032225@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202506142026.55EKQeGM032225@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4bKwmx3dCgz3gyM X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:12876, ipnet:51.15.0.0/17, country:FR] On Sat, Jun 14, 2025 at 08:26:40PM +0000, Hiroki Sato wrote: > The branch main has been updated by hrs: > URL: https://cgit.FreeBSD.org/src/commit/?id=7faddeb395b7976b44393db24f48ec47040eff07 > commit 7faddeb395b7976b44393db24f48ec47040eff07 > Author: Hiroki Sato > AuthorDate: 2025-06-14 20:24:41 +0000 > Commit: Hiroki Sato > CommitDate: 2025-06-14 20:24:41 +0000 > rc: Fix scripts that need pathname expansion > Reported by: Kenneth Raplee > Differential Revision: https://reviews.freebsd.org/D45855 > diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr > index 359eebd1d342..d760b75a15a3 100644 > --- a/libexec/rc/rc.subr > +++ b/libexec/rc/rc.subr > @@ -223,10 +223,11 @@ rc_trace() > list_vars() > { > # Localize 'set' option below. > - local - > + local - _s > local IFS=$'\n' line varname > > - # Disable path expansion in unquoted 'for' parameters below. > + # Disable path expansion temporarily in unquoted 'for' parameters below. > + _s=$(set +o) Like the comment says, `local -` already saves and restores `set` options, so it does not make sense to do it again manually. If you want to stop using `local -` in rc and use `_s=$(set +o)`, etc., please do so consistently. > set -o noglob > > for line in $(set); do > @@ -241,6 +242,7 @@ list_vars() > ;; > esac > done > + eval $_s > } > > # set_rcvar [var] [defval] [desc] > @@ -292,6 +294,19 @@ set_rcvar_obsolete() > eval ${_var}_obsolete_msg=\"$*\" > } > +# expandpath str > +# Apply pathname expansion to str. > +# > +expandpath() > +{ > + local _s > + > + _s=$(set +o) > + set +o noglob > + echo $1 > + eval $_s > +} > + This is convenient but it should be kept in mind that unlike direct pathname expansion it will not handle correctly pathnames containing spaces. A comment may be appropriate. If you do not want to use `local -`, I would prefer `eval "$_s"` instead of `eval $_s` since not using the quotes requests word splitting which is not needed (although it should not break anything either). -- Jilles Tjoelker