aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2024-10-07 21:00:38 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2024-10-07 21:01:09 +0000
commita0dfb0668b45506de97beb4c7acbe3fd1ba69fc8 (patch)
treef8705f9cbde42fc9bbf881163c62a492ee184621
parent334af5e4131b21c658203635bf713d6a59846585 (diff)
-rw-r--r--usr.bin/env/env.128
-rw-r--r--usr.bin/env/tests/env_test.sh20
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
}