All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] man/man7/environ.7: Fix underspecification of "name=value" strings
@ 2026-07-06 14:26 Jason Yundt
  2026-07-06 15:27 ` Alejandro Colomar
  2026-07-07 10:53 ` [PATCH v2] " Jason Yundt
  0 siblings, 2 replies; 6+ messages in thread
From: Jason Yundt @ 2026-07-06 14:26 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Jason Yundt, linux-man

Before this change, environ(7) said this:

> By convention, the strings in environ have the form "name=value".  The
> name is case-sensitive and may not contain the character "=".  The
> value can be anything that can be represented as a string.  The name
> and the value may not contain an embedded null byte ('\0'), since this
> is assumed to terminate the string.

That description has a few problems:

1. It talks about ‘the character "="’, but it doesn’t specify what
   character encoding would be used to represent that character.  Two
   different character encodings could represent that same “=” character
   using two different bytes (or even sequences of bytes).

2. It mentions that ‘The name is case-sensitive and may not contain the
   character "=".’  It doesn’t clearly say what what is allowed to be in
   a name.  It only says that those two things are explicitly
   disallowed.

This change fixes those two problems.  For the first problem, this
change makes it so that the description is all about bytes, not
characters.  Describing the format in terms of bytes allows us to
sidestep the question of character encoding entirely.  Additionally, it
is more accurate to describe strings in environ as being sequences of
bytes instead of sequences of characters.  Both the name and value of an
environment variable could be sequences of bytes that don’t contain any
characters at all.

For the second problem, this change clarifies that the name of an
environment variable can contain any byte except for 0x3D.  It also
clarifies that while it’s OK for environment variable values to be
empty, it’s not OK for environment variable names to be empty.

Additionally, this change replaces "=" with '='.  In the C programming
language, "=" refers to two bytes: one for the equals character plus one
for the terminating null byte.  In the C programming language, '='
refers to a single byte.  In this particular instance, we’re talking
about a single byte, so it’s better to use '='.  Using '=' also makes
environ(7) more internally consistent.  Before this change, environ(7)
used '\0' and "=".  This change makes it so that environ(7) uses '\0'
and '='.

I was able to obtain obtain the information that I needed in order to
create this change by writing a test program.  You can find the test
program here [1].  Additionally, I got the information about the setenv(3)
and unsetenv(3) functions from their man pages (specifically, the parts
of their man pages that talk about EINVAL).

[1]: <https://codeberg.org/JasonYundt/environ-format-example-program>

Signed-off-by: Jason Yundt <jason@jasonyundt.email>
---
 man/man7/environ.7 | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/man/man7/environ.7 b/man/man7/environ.7
index 31a69017cf75..bf5726e32429 100644
--- a/man/man7/environ.7
+++ b/man/man7/environ.7
@@ -28,12 +28,23 @@ .SH DESCRIPTION
 .I environ
 have the form
 .RI \[dq] name\f[B]=\f[]value \[dq].
-The name is case-sensitive and may not contain
-the character
-.RB \[dq] = \[dq].
-The value can be anything that can be represented as a string.
-The name and the value may not contain an embedded null byte (\[aq]\[rs]0\[aq]),
-since this is assumed to terminate the string.
+The name is case-sensitive
+and may contain any byte
+other than null (\[aq]\[rs]0\[aq]) and 0x3D (the
+.BR ascii (7)
+.RB \[aq] = \[aq]
+character).
+The name must be at least one byte long,
+or else programs will not be able to manipulate it using the
+.BR setenv (3)
+or
+.BR unsetenv (3)
+functions.
+Immediately after the name, there should be a 0x3D byte.
+Immediately after the 0x3D byte is the value.
+The value may contain any byte except for null.
+The value may be zero bytes long.
+Immediately after the value, there must be a terminating null byte.
 .P
 Environment variables may be placed in the shell's environment by the
 .I export

Range-diff against v0:
-:  ------------ > 1:  d5b0d9b86029 man/man7/environ.7: Fix underspecification of "name=value" strings
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-07 11:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 14:26 [PATCH v1] man/man7/environ.7: Fix underspecification of "name=value" strings Jason Yundt
2026-07-06 15:27 ` Alejandro Colomar
2026-07-07 10:54   ` Jason Yundt
2026-07-07 11:23     ` Alejandro Colomar
2026-07-07 10:53 ` [PATCH v2] " Jason Yundt
2026-07-07 11:31   ` Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.