|
From: | Ivan Vučica |
Subject: | Re: NSHost name |
Date: | Sun, 20 Apr 2014 01:12:47 +0200 |
If you look at the documentation (either the GNUstep documentation or the Apple documentation) you will see that your expectation is misguided ... the -name method returns *a* name of the host, not necessarily any particular one.
On 18 Apr 2014, at 15:37, Riccardo Mottola <riccardo.mottola@libero.it> wrote:
> Hi,
>
> Given this situation:
>
> # hostname
> hobbit
>
> # hostname -a
> localhost
>
>
> I'd expect [[NSHost currentHost] name] to return the name, not the alias.
If you have code which prefers particular names, you should use the -names method to get all the names for the host, and then use some heuristic to pick the one you prefer to use.
Eg, you might want a name without the domain component (so you'd exclude names containing dots) and you might want to exclude localhost, and then perhaps you might want to pick the first shortest remaining name in alphabetical order.
All that being said ... I suspect the behavior you are looking for is that of the -localizedName method Apple added in OSX 10.6
I've just hacked in a quick implementation (untested) in svn trunk that you could try.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
[Prev in Thread] | Current Thread | [Next in Thread] |