[comp.sys.hp] Strangeness with csh environment variable names?

sartin@hplabsz.HPL.HP.COM (Rob Sartin) (05/25/90)

In article <777@limbo.Intuitive.Com> taylor@limbo.Intuitive.Com (Dave Taylor) writes:
>While working on a program, I had reason to create a new environment
>variable called "PROG-OPTS".  Much to my surprise, however, having a
>value of that sort in my csh environment caused all sorts of havoc!!

Well, the problem is:

1) The system(3) routine uses /bin/sh to run the string that is passed
    to system().

2) The Bourne shell (and Korn shell) limits a "name":

	A blank is a tab or a space.  A name is a sequence of letters,
	digits, or underscores beginning with a letter or underscore.

    and an environment variable must be a "name".

So, when the system() library routine runs the shell to run your
command, the shell is getting an error because one of the environment
variables is not a valid "name".

Unfortunately, the only workaround is "don't do that".  The behaviour is
the same on my 7.0 series 300 machine (in case you care, the Korn shell
error message is "invalid identifier" rather than the "is not an
identifier" given by the Bourne shell).

I would suspect that the behaviour won't change since it was inherited from
AT&T and is probably in some important standard somewhere.

Disclaimer:  I don't work on the HP-UX product and don't speak for
Hewlett-Packard.

Rob Sartin			internet: sartin@hplabs.hp.com
Software & Systems Lab	 	uucp    : hplabs!sartin
Hewlett-Packard			voice	: (415) 857-7592

guy@auspex.auspex.com (Guy Harris) (05/26/90)

>I would suspect that the behaviour won't change since it was inherited from
>AT&T and is probably in some important standard somewhere.

And even if it isn't, that behavior is sufficiently widespread (as in "I
know of no UNIX systems that *don't* exhibit it, and I wouldn't be
surprised to hear there are none) that one is best advised to use
underscore rather than dash in environment variable names.  "PROG_OPTS"
is a better choice.