From nobody Mon Oct 07 21:01:34 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 4XMs5V6cR9z5YSTZ; Mon, 07 Oct 2024 21:01:34 +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 4XMs5V5zjBz554k; Mon, 7 Oct 2024 21:01:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728334894; 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=UPnKIu8IWEH4Emg1rUW3mM2ptqPms1iOecMaWXfSeRc=; b=cHzgWCtmR06xENfLLSNwmMZatN3TWFOJuBEwU36spe51++HuMN55xyyBRVQFYCGzDxMJ3i LbPu5EOSC7tUi3T6YrL9WzqIDazQSvHiiibIwRo0lAuL71aWNSb9riHljw07HNzXaITdOn m+wG0/5y/Uzh+IBo9rffP+Gx+/abPNI113H40VRnubJaI6JuZI4SpapEr5UhQ/5TkNdQPJ 1yKV+gZFMJIQ4q/y+UA8CZdB+YXXgDJxExIZEWn0xRSodrn8qeilzEP/w9w7REGFbgXY8u Uy5u3P0EBTJMwB/lEw3qvH2i78SuwIw8phptBdKNF6xQU+cY0x+Zy5ydblQ4ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728334894; 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=UPnKIu8IWEH4Emg1rUW3mM2ptqPms1iOecMaWXfSeRc=; b=IS//aIw3/oaCWVCVVCp8Je6S3lXhZd7xW8Og5uG0wT8AJzqFTyJHjUaCapN2bF/U6b8HOf nIX/gBA08+54OmjQLWpPC16YIc9YpAInhXufziCskB/EXR3SVZqSjiyrNfRJe00X+N0jq2 4Nq6JEgbzAfRliL5mSAspq77rqzdtX34p3SMzfB0N0l9+6VhPOZoivNfgT7e5wRXFIRcW8 /l7OCxKn+ZFozrcWvA7eT6e5BozQPNt2R+sgQmeTlfLXfQPDYGebeMQ0TVde26bLQ2NE7o itjULtozP3IjBiL7BD11O8GO1jn2WZbug9NG9THzpCo6EXP+8pCuI9YBVM/FKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728334894; a=rsa-sha256; cv=none; b=k1IFuDY7rwBhmi/J0D9vVJHRSXTCQkJw4TcA9V6GeAZQiSHmSzqLuh6NlMLMDh+m7c2h6j 9MPRSexSwtSHnJKO+vVFz4J0CVfizpC30Yq8j3g2lzahdFOpFtBEOouTwfsuW1TchCiq/+ t/QgsqZ92EpnplHH4epsWNFFU4u9tVaPLaQshdaFesjfqyc/ixCHApom9lkCjSrF0y5SVa ytV3vVrHSxH659la1Ar7o6qEsCH8pgKf+oRguqQrbfnlk1vEpVao41Ga/QzAd2AaPUBx4b Px9xShv05KnvAemnjb2IyKfAx5oeCIDLXNCMLVWPbemPRdzg2iguZPBnJDa0UA== 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 4XMs5V5bD6z12V6; Mon, 7 Oct 2024 21:01:34 +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 497L1Y15027082; Mon, 7 Oct 2024 21:01:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 497L1YwG027079; Mon, 7 Oct 2024 21:01:34 GMT (envelope-from git) Date: Mon, 7 Oct 2024 21:01:34 GMT Message-Id: <202410072101.497L1YwG027079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: a0dfb0668b45 - main - env: Improve documentation. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a0dfb0668b45506de97beb4c7acbe3fd1ba69fc8 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=a0dfb0668b45506de97beb4c7acbe3fd1ba69fc8 commit a0dfb0668b45506de97beb4c7acbe3fd1ba69fc8 Author: Dag-Erling Smørgrav AuthorDate: 2024-10-07 21:00:38 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-10-07 21:01:09 +0000 env: Improve documentation. * The `env` utility's inability to run a command whose name contains an equal sign is a feature, not a bug, so move that paragraph up from the BUGS section to the DESCRIPTION section. * Mention that this can be worked around by prefixing the command name with `command`, and add an example of this to the EXAMPLE section. * Add a test case which verifies that `env` does not run a command with an equal sign in its name even if it exists, and also demonstrates the workaround. MFC after: 3 days Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D46997 --- usr.bin/env/env.1 | 28 +++++++++++++++++++--------- usr.bin/env/tests/env_test.sh | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/usr.bin/env/env.1 b/usr.bin/env/env.1 index 2b98ef40d053..5581d3838a7b 100644 --- a/usr.bin/env/env.1 +++ b/usr.bin/env/env.1 @@ -28,7 +28,7 @@ .\" SUCH DAMAGE. .\" From FreeBSD: src/usr.bin/printenv/printenv.1,v 1.17 2002/11/26 17:33:35 ru Exp .\" -.Dd March 3, 2021 +.Dd October 7, 2024 .Dt ENV 1 .Os .Sh NAME @@ -171,6 +171,19 @@ Both and .Ar utility may not be specified together. +.Pp +The +.Nm +utility does not handle values of +.Ar utility +which have an equals sign +.Pq Ql = +in their name, for obvious reasons. +This can easily be worked around by interposing the +.Xr command 1 +utility, which simply executes its arguments; see +.Sx EXAMPLES +below. .\" .Ss Details of -S (split-string) processing The processing of the @@ -469,6 +482,11 @@ and options: .Pp .Dl "#!/usr/bin/env -S-P/usr/local/bin:/usr/bin:${PATH} perl" +.Pp +To execute a utility with an equal sign in its name: +.Bd -literal -offset indent +env name=value ... command foo=bar arg ... +.Ed .Sh COMPATIBILITY The .Nm @@ -514,14 +532,6 @@ options were added in .Sh BUGS The .Nm -utility does not handle values of -.Ar utility -which have an equals sign -.Pq Ql = -in their name, for obvious reasons. -.Pp -The -.Nm utility does not take multibyte characters into account when processing the .Fl S diff --git a/usr.bin/env/tests/env_test.sh b/usr.bin/env/tests/env_test.sh index 7568f81ab603..da238caaf7fa 100644 --- a/usr.bin/env/tests/env_test.sh +++ b/usr.bin/env/tests/env_test.sh @@ -89,6 +89,25 @@ altpath_body() env -P "${PWD}" magic_words } +atf_test_case equal +equal_head() +{ + atf_set "descr" "Command name contains equal sign" +} +equal_body() +{ + echo "echo ${magic_words}" >"magic=words" + chmod 0755 "magic=words" + atf_check -o match:"^${PWD}/magic=words$" \ + env "${PWD}/magic=words" + atf_check -o match:"^magic=words$" \ + env -P "${PATH}:${PWD}" "magic=words" + atf_check -o inline:"${magic_words}\n" \ + env command "${PWD}/magic=words" + atf_check -o inline:"${magic_words}\n" \ + env PATH="${PATH}:${PWD}" command "magic=words" +} + atf_init_test_cases() { atf_add_test_case basic @@ -97,4 +116,5 @@ atf_init_test_cases() atf_add_test_case true atf_add_test_case false atf_add_test_case altpath + atf_add_test_case equal }