[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: es variables



Jeffrey Rogers wrote
> I've been using es-0.9-alpha1 for a while now, with few problems (mostly 
> dealing with working in an environment oriented toward sh/ksh/csh users).

It is painful at times.  Sorry about that.

> I recently noticed something odd with variables:
> 
> For variables like LD_LIBRARY_PATH I sometimes have to append or prepend
> something to the existing path, which is a : seperated list (just like
> PATH).  I normally do this using
> ; LD_LIBRARY_PATH=newpart:$LD_LIBRARY_PATH
> which works fine if LD_LIBRARY_PATH is already set.  However, if it is
> not set, then newpart:$LD_LIBRARY_PATH evaluates to nothing, instead of
> "newpart:" as I expect.  Adding carats doesn't help.  It doesn't matter
> if the variable is before or after the plaintext.  e.g.
> ; echo a$b $b^a a
> a
> ; b=foo           
> ; echo a$b $b^a a
> afoo fooa a
> ; 
> 
> Is this correct behavior?

Well, let's just say it's doing what it's specified to do.  The problem
is that there is no distinction between words and lists of words in
concatenation.

Whether it's what it should be doing is another story.  This is one of
those places es diverged from rc for some abstract notion of perfect
internal consistency, at the expense of being painful to use in practice.

(Translation of the previous comment:  it's my fault, not Byron's.)

> Or is it a bug (perhaps only only local version)?

No such luck.

> If it is correct behavior, I guess I could copy a PATH-style settor
> for my original problem, but how would one normally go about adding
> text to a variable that is possibly null?

The workaround I've used is

  LD_LIBRARY_PATH=newpart:$^LD_LIBRARY_PATH

where $^var creates a single word from the variable, which is '' if the
variable is a 0-length list.  The multiple components are concatenated
with spaces, but that shouldn't hurt, since a multi-component
LD_LIBRARY_PATH is probably a mistake.

> I'm not on the list (yet; I just sent my subscription notice to
> -request) but I didn't see anything like this in the list archive.

(That may have prevented your note from going to the whole list, as part
of cks's crackdown on spamming.)

Paul