Howdy guys,
I just wanted to point something out.
(bash)
$ echo $USER
me
$ echo $HOSTNAME
the-name
(newlisp)
(env "USER")
me
(env "HOSTNAME")
nothing
And the hostname is not "nothing" :-) ("env" doesn't return anything) Why is this?
Which version of newLisp are you using? Because in my Linux environment:
Quote
peter[~]$ echo $USER
peter
peter[~]$ echo $HOSTNAME
solarstriker.thuis.nl
peter[~]$ newlisp
newLISP v.9.4.5 on Linux IPv4, execute 'newlisp -h' for more info.
> (env "USER")
"peter"
> (env "HOSTNAME")
"solarstriker.thuis.nl"
>
...it works as advertised....?
Peter
I don't think it works on all platforms...
$ echo $HOSTNAME
imac.local
$ newlisp
newLISP v.9.4.5 on OSX IPv4 UTF-8, execute 'newlisp -h' for more info.
> (env "HOSTNAME")
nil
newLISP v.9.4.8 64-bit on Linux IPv4 UTF-8
Quote from: "cormullion"
I don't think it works on all platforms...
It's probably not a matter of not "working", but simply not being defined on all platforms. HOSTNAME is not a default environment variable on WIN XP, for example.
But if your platform doesn't have it, you can always define it yourself.
Its also a matter of what is passed on from the environment to the newLISP process. E.g. on Mac OS X HOSTNAME is defined when in the shell but not inside newLISP. But 'exec' can be used to still retrieve it on Unix:
> (env "HOSTNAME")
nil
> (exec "echo $HOSTNAME")
("lutzmacmini")
>
On BSD like Unices like Mac OS X use the man-page for environ to find out what is available at the shell prompt:
$ man environ
environ is a C variable maintained by the OS and used inside newLISP to read the environment. On Windows the same C variable is maintained.