Bug 60300

Summary: tcsh should not let you set environment variables with '=' in their names
Product: [Retired] Red Hat Raw Hide Reporter: Jonathan Kamens <jik>
Component: tcshAssignee: Miloslav Trmač <mitr>
Status: CLOSED CURRENTRELEASE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-08-19 14:29:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jonathan Kamens 2002-02-24 23:44:40 UTC
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 15:16:38 UTC
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 15:28:07 UTC
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 14:29:18 UTC
This is fixed in tcsh-6.12-8 and tcsh-6.13-1.