[squeak-dev] The Inbox: System-laza.423.mcz
David T. Lewis
lewis at mail.msen.com
Tue Feb 22 15:14:50 UTC 2011
FYI, the OSProcessPlugin distributed with unix VMs provides these:
<primitive: 'primitiveEnvironmentAt:' module: 'UnixOSProcessPlugin'>
<primitive: 'primitiveEnvironmentAtSymbol:' module: 'UnixOSProcessPlugin'>
For Windows it is this (but the plugin is not distributed):
<primitive: 'primitiveGetEnvironmentStrings' module. 'Win32OSProcessPlugin'>
On Tue, Feb 22, 2011 at 11:45:30AM +0100, Alexander Lazarevi?? wrote:
> I would like to add this to the trunk. This would allow an image running on
> linux to read an envVar that points to a central directory of sources files
> (see thread ).
> On other platforms the environment dictionary is just empty.
> This could be easily changed in the future when the VMs on all platforms
> might offer a primitive to access the os envVars.
> 2011/2/22 <commits at source.squeak.org>
> > Alexander Lazarević uploaded a new version of System to project The
> > Inbox:
> > http://source.squeak.org/inbox/System-laza.423.mcz
> > ==================== Summary ====================
> > Name: System-laza.423
> > Author: laza
> > Time: 22 February 2011, 11:31:19.136 am
> > UUID: 2c296259-64d4-499d-b4b5-9a4046d737fa
> > Ancestors: System-ul.422
> > Add support for accessing OS environment variables (on linux at first)
> > =============== Diff against System-ul.422 ===============
> > Item was added:
> > + ----- Method: SmalltalkImage>>environ (in category 'os') -----
> > + environ
> > + "Smalltalk os environ"
> > + | env c in match out name |
> > + env := IdentityDictionary new.
> > + self os osVersion = 'linux' ifFalse: [^env]. "Currently only
> > supported on linux"
> > + in := FileStream oldFileOrNoneNamed: '/proc/self/environ'.
> > + in ifNil: [^env].
> > + out := WriteStream on: String new.
> > + match := $=.
> > + [(c := in next) isNil] whileFalse: [
> > + c = match
> > + ifTrue: [
> > + c = $= ifTrue: [name := out contents. match
> > := 0 asCharacter].
> > + c = 0 asCharacter ifTrue: [env at: name
> > asSymbol put: out contents. match := $=].
> > + out reset]
> > + ifFalse: [out nextPut: c]].
> > + ^env!
> > Item was added:
> > + ----- Method: SmalltalkImage>>getEnv: (in category 'os') -----
> > + getEnv: name
> > + "Smalltalk os getEnv: 'HOME'"
> > + ^self os environ at: name asSymbol ifAbsent: [nil]
> > + !
More information about the Squeak-dev