1 prototypes define: #Platform
7 #endianness -> #LittleEndian.
10 p@(Platform traits) update
13 [name: (lobby systemPlatform as: String).
14 nodeName: (lobby systemName as: String).
15 systemRelease: (lobby systemRelease as: String).
16 systemVersion: (lobby systemVersion as: String).
17 machine: (lobby systemMachine as: String).
18 endianness: (lobby isLittleEndian ifTrue: [#LittleEndian] ifFalse: [#BigEndian]).
19 bytesPerWord: lobby bytesPerWord. ]
22 p@(Platform traits) current
25 Platform traits define: #Current &builder: [Platform current].
27 p@(Platform traits) isPosix
28 "Whether the underlying platform implements (enough of?) the POSIX API."
29 "TODO: figure out a way to really determine/configure this."
32 p@(Platform traits) run: command
33 [lobby systemExecute: command].
35 Image startupActions at: #Platform put:
37 Platform Current update
40 globals define: #Environment &parents: {Mapping. ExtensibleCollection}
41 &slots: {#variables -> Dictionary new}.
43 Image startupActions at: #Environment put:
46 e@(Environment traits) update
48 variables: lobby environmentVariables.
49 e variables: (e variables newSizeOf: variables).
51 [| :each eachString equalsIndex key value |
52 eachString: (each as: String).
53 equalsIndex: (eachString indexOf: $= ifAbsent: [eachString length]).
54 key: (eachString first: equalsIndex).
55 value: (eachString allButFirst: equalsIndex + 1).
56 e variables at: key put: value].
59 e@(Environment traits) size
64 e@(Environment traits) capacity
69 _@(Environment traits) acceptsKey: _
72 _@(Environment traits) acceptsKey: _@(String traits)
75 _@(Environment traits) accepts: _
78 _@(Environment traits) accepts: _@(String traits)
81 _@(Environment traits) defaultElement
84 e@(Environment traits) at: name ifAbsent: block
86 e variables at: name ifAbsent: block
89 e@(Environment traits) at: name put: value
91 lobby environmentAt: name put: value.
92 e variables at: name put: value
95 e@(Environment traits) removeKey: name ifAbsent: block
97 (e variables includesKey: name) ifTrue: [lobby environmentRemoveKey: name].
98 e variables removeKey: name ifAbsent: block
101 e@(Environment traits) keyAtValue: obj ifAbsent: block
103 e variables keyAtValue: obj ifAbsent: block
106 e@(Environment traits) keysAndValuesDo: block
108 e variables keysAndValuesDo: block
111 e@(Environment traits) allSatisfy: block
113 e variables allSatisfy: block
116 e@(Environment traits) printOn: s [s ; e printName].
118 e@(Environment traits) homePath [e at: 'HOME'].
119 e@(Environment traits) currentPath [e at: 'PWD'].
120 e@(Environment traits) temporaryPath [e at: 'TMPDIR'].
121 e@(Environment traits) includedPaths
122 "Where the shell expects to find binary executables."
123 [(e at: 'PATH') ifNotNilDo: [| :paths | paths splitWith: $:]].
124 e@(Environment traits) userName [e at: 'LOGNAME'].
125 e@(Environment traits) terminalType [e at: 'TERM'].
127 e@(Environment traits) sourcePaths
128 "Where Slate expects to find code."
129 [(e at: 'SLATEPATH') ifNil: [{}] ifNotNilDo: [| :paths | paths splitWith: $:]].
131 "Load defaultPaths addAll:
132 (Environment sourcePaths collect: [| :each | each as: File Locator])."
134 define: #shell &builder: [lobby newSubSpace].
136 _@shell didNotUnderstand: message at: position
137 "Form a command string and execute it."
143 message selector isUnarySelector
145 [command ; message selector.
146 message optionals pairsDo:
148 command ; ' -' ; (key as: String) allButFirst allButLast ; ' ' ; (value as: String)]].
149 message selector isKeywordSelector ifTrue:
151 keywords: ((message selector as: String) splitWith: $:).
152 command ; keywords first.
153 keywords size = 1 ifTrue: "Read a string or array of arguments."
154 [args: message arguments second.
155 (args is: String) ifTrue: [command ; ' ' ; args]
156 ifFalse: [args do: [| :arg | command ; ' ' ; arg]]]].
157 message arguments allButFirst: message selector arity do:
158 [| :arg | command ; ' ' ; (arg as: String)]] writingAs: String)
159 ifNil: [resend] ifNotNilDo: [| :cmd | [Platform run: cmd]]]