Bug 60300 - tcsh should not let you set environment variables with '=' in their names
Summary: tcsh should not let you set environment variables with '=' in their names
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: tcsh
Version: 1.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Miloslav Trmač
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-02-24 23:44 UTC by Jonathan Kamens
Modified: 2007-04-18 16:40 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-08-19 14:29:18 UTC
Embargoed:


Attachments (Terms of Use)

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.


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