Bug 60300 - tcsh should not let you set environment variables with '=' in their names
tcsh should not let you set environment variables with '=' in their names
Status: CLOSED CURRENTRELEASE
Product: Red Hat Raw Hide
Classification: Retired
Component: tcsh (Show other bugs)
1.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Miloslav Trmač
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-02-24 18:44 EST by Jonathan Kamens
Modified: 2007-04-18 12:40 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-08-19 10:29:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 2002-02-24 18:44:40 EST
tcsh doesn't complain if you say "setenv FOO=BAR" instead of "setenv FOO BAR". 
Instead, it creates the environment variable "FOO" with the value "BAR=".  This
is exceedingly broken.  Tcsh should reject environment variable names with "="
in them.
Comment 1 Eido Inoue 2002-02-25 10:16:38 EST
Why not? Other shells let you have environment variables with special characters
(including '=') in them. I can't name an app that uses special characters (other
than the underscore) in env var names, but tcsh is parsing according to its
rules in determining that the '=' goes in.
Comment 2 Jonathan Kamens 2002-02-25 10:28:07 EST
I challenge you to name a single other shell which will allow you to create an
environment variable with "=" in its NAME, not its VALUE.  There is none, as far
as I know.  It's impossible to do in any sh-compatible shell because the first
"=" in the variable assignment is always considered the division between the
name and value of the variable.  Ditto for zsh.

Three other proofs that tcsh's behavior is broken:

1) The environ(5) man page says, "By convention, these strings have the form
`name=value'."  Obviously, if that's how variables are stored in the
environment, it's impossible for a variable name to have "=" in it.

2) If you run "setenv FOO bar" and then "setenv FOO=bar" in tcsh, you end up
with two settings of "FOO" in the environment:

jik:~!148> setenv FOO bar
jik:~!149> setenv FOO=bar
jik:~!150> setenv | grep FOO
FOO=bar
FOO=bar=
jik:~!151> 

In other words, the environment is now corrupt.

3) If you set an environment variable with an equal sign in it, it's impossible
to get back the same environment variable:

jik:~!151> unsetenv FOO
jik:~!152> setenv FOO=bar
jik:~!153> echo $FOO=bar
bar==bar
jik:~!154> echo ${FOO=bar}
Missing }.
jik:~!155> 

Note that command 153 above is interpreted as a reference to the variable FOO,
which tcsh thinks has the value "bar=" because of this brokenness, followed by
the string "=bar".
Comment 3 Miloslav Trmač 2004-08-19 10:29:18 EDT
This is fixed in tcsh-6.12-8 and tcsh-6.13-1.

Note You need to log in before you can comment on or make changes to this bug.