On Thu, 13 Mar 2008, Ned Freed wrote:
...
>> There is a "host" item listed, which is the FQDN of the local host. It
>> seems to me that one might want to know the host-only part of that
>> string. One could obtain it in a round-about way by using the "domain"
>> environment item and the "host" item; but is it worth adding
>> "host-only" ?
>
> Frankly, I think the use of shortform names is a bad thing that should
> be discouraged whenever possible. (IT uses them extensively here at Sun
> and they cause no end of problems.) I'm therefore very reluctant to add
> such an item.
I agree. Unqualified hostnames should never appear in protocols and,
IMHO, are only useful in space-constrained interactive environments, where
the user can obtain the full form if they have any doubt.
...
> First of all, the specification says that any test against an unknown
> item must fail unconditionally. This provides a simple way to check and
> see if a given item is available:
>
> if environment :matches "item" {...}
There's a pattern missing there.
Right, sorry about that.
Regardless, the empty substring test is
probably more efficient:
if environment :contains "item" "" { ... }
This almost always works, but not in the case where the environment
item has the null string as a possible return value. Of course in every
case I can think of a null value is going to signify "information not
available", and I cannot think of a use-case where a script would want
to act differently given "item not supported' versus "information not
available".
Ned