variable length in the csh

Steve Thomas sthomas at garth.UUCP
Sat Sep 29 08:51:18 AEST 1990


In article <25872 at shamash.cdc.com> mek at enterprise.udev.cdc.com (Mark Kennedy) writes:

>Can anybody tell me what the maximum length for a variable is in the
>C-shell?  In my experience on both Sun workstation and MIPS the
>limit is a mere 18 characters.
The answer is, as usual, it depends.  (Do I get my guru badge now? 8-)

The parse-a-variable code inside the C-shell is inserted in line
wherever it's required.  As a result, the maximum length permitted (and,
come to that, the legal characters in the name of the variable) varies
depending on the exact syntax.  It's always at least 18, and
occasionally 19 or 20.  Except for arrays, of course, when it goes up to
about 40 some of the time.

There is, of course, the possibility that particular vendors may have
fixed this farrago and imposed a possibly different and more consistent
limit.  Portable scripts will use only 18 characters or less.

To forestall any queries, a variable name is supposed to be
[A-Za-z][A-Za-z0-9]*, though in some places csh permits a digit in the
first position and/or forbids digits in the rest.  Again, some vendors
may have fixed this `feature'.  Portable scripts should only use letters
in variable names.

Steve Thomas



More information about the Comp.unix.questions mailing list