[squeak-dev] The Trunk: System-dtl.1062.mcz

commits at source.squeak.org commits at source.squeak.org
Mon May 6 02:55:00 UTC 2019


David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.1062.mcz

==================== Summary ====================

Name: System-dtl.1062
Author: dtl
Time: 5 May 2019, 10:54:56.642077 pm
UUID: c527ef41-51fb-4e49-b00a-90a9a09a935d
Ancestors: System-cmm.1061

If CodeLoader is loading a script that begins with a Unix shebang line, then skip over line one of the script. This accomodates the case of an executable Unix shell script that starts a Squeak image, then feeds itself to Squeak as a start script. For example, an executable script file might contain this:

#!/usr/local/bin/squeak --
Transcript show: 'Hello, world'; cr.

=============== Diff against System-cmm.1061 ===============

Item was added:
+ ----- Method: CodeLoader>>allButShebangLine: (in category 'private') -----
+ allButShebangLine: contentsString
+ 	"If tontentsString begins with '#!!' then assume that it contains a Unix
+ 	shebang line should be skipped prior to evaluating the contents."
+ 	
+ 	(contentsString beginsWith: '#!!')
+ 		ifTrue: [contentsString lineIndicesDo: [:line :end :endOfLine |
+ 			^ contentsString allButFirst: endOfLine ]]
+ 		ifFalse: [^ contentsString]
+ 
+ 	" CodeLoader new allButShebangLine:
+ '#!!/usr/llocal/bin/squeak --
+ Transcript cr; show: ''Hello world!!''
+ ' "!

Item was changed:
  ----- Method: CodeLoader>>installSourceFile: (in category 'installing') -----
  installSourceFile: aStream
  	"Install the previously loaded source file"
  	| contents trusted |
  	aStream ifNil:[^self error:'No content to install'].
  	trusted := SecurityManager default positionToSecureContentsOf: aStream.
  	trusted ifFalse:[(SecurityManager default enterRestrictedMode) 
  					ifFalse:[ aStream close.
  							^ self error:'Insecure content encountered']].
+ 	contents := self allButShebangLine: aStream upToEnd unzipped asString.
- 	contents := aStream upToEnd unzipped asString.
  	(aStream respondsTo: #close) ifTrue:[aStream close].
  	^contents readStream fileIn!



More information about the Squeak-dev mailing list