[squeak-dev] The Inbox: System-dtl.1197.mcz

David T. Lewis lewis at mail.msen.com
Fri Dec 18 03:46:21 UTC 2020


I would like to merge this into trunk, but here is my concern.

With these changes applied, on Unix I can do this to run an image with a start document:

  $ squeak squeak.image startDocument

Or I can do this to prevent the last argument from being treated as a start document:

  $ squeak squeak.image -- somethingThatIsNotAStartDocument

However, on Windows I do not know if there is a similar way to handle somethingThatIsNotAStartDocument.

Is this a problem?

Thanks,
Dave


On Sun, Dec 13, 2020 at 12:18:01PM -0500, David T. Lewis wrote:
> This update addresses a couple of annoyances in our current startup argument processing.
> 
> Annoyance #1: If someone starts the image like this:
> 
>   $ squeak squeak.image -e '3 + 4'
> 
> Then is it clear that the '-e' parameter should not be interpreted as a start document.
> 
> Annoyance #2: Having a preference for #readDocumentAtStartup makes the startup
> logic more complicated than it needs to be. It's just one more thing to keep
> track of, and if my command line does not work as expected I have to remember
> to go check the setting.
> 
> So if we can get rid of a preference and make the system a little bit simpler,
> that would be a good thing.
> 
> I cannot think of any use case on a unix-like system for which these changes
> would cause a problem, but it is possible that I am overlooking an issue
> that would affect Windows or other platforms.
> 
> If someone with Windows experience could have a look at this update, I would
> appreciate any feedback.
> 
> Thanks,
> Dave
> 
> 
> On Sun, Dec 13, 2020 at 04:53:27AM +0000, commits at source.squeak.org wrote:
> > A new version of System was added to project The Inbox:
> > http://source.squeak.org/inbox/System-dtl.1197.mcz
> > 
> > ==================== Summary ====================
> > 
> > Name: System-dtl.1197
> > Author: dtl
> > Time: 12 December 2020, 11:39:02.946469 pm
> > UUID: 98a9eb0b-d360-473f-a718-f1f7ae883ac7
> > Ancestors: System-mt.1196
> > 
> > Enable removal of preference for 'Read document at startup'.
> > 
> > Simplify code such that #readDocumentAtStartup is assumed always true and document specifiers begining with '-' are not treated as start documents. The actual preference setting is no longer referenced.
> > 
> > Assumptions: if the start document resource name starts with '-' then it is unlikely to be a document. For the case of the first argument appearing to be a document but the user wishing to use it otherwise, the '--' token (or any other argument beginning with '-') may be used in the command line to protect the argument from evaluation. This allows the traditional start document processing to work normally in the general case, and allows start document processing to be bypassed from the command line if desired. No preference setting is required. 
> > 
> > The #readDocumentAtStartup may be removed in a future update.
> > 
> > =============== Diff against System-mt.1196 ===============
> > 
> > Item was changed:
> >   ----- Method: ProjectLauncher>>startUpAfterLogin (in category 'running') -----
> >   startUpAfterLogin
> >   	| scriptName loader isUrl |
> >   	self setupFlaps.
> > + 	Smalltalk firstArgMightBeDocument
> > + 		ifTrue: [scriptName := Smalltalk documentPath.
> > - 	Preferences readDocumentAtStartup
> > - 		ifTrue: [scriptName := Smalltalk documentPath
> > - 						ifNil: [''].
> >   			scriptName := scriptName convertFromSystemString.
> >   			scriptName isEmpty
> >   				ifFalse: ["figure out if script name is a URL by itself"
> >   					isUrl := (scriptName asLowercase beginsWith: 'http://')
> >   								or: [(scriptName asLowercase beginsWith: 'file://')
> >   										or: [scriptName asLowercase beginsWith: 'ftp://']].
> >   					isUrl
> >   						ifFalse: [| encodedPath pathTokens |
> >   							"Allow for ../dir/scriptName arguments"
> >   							pathTokens := scriptName splitBy: FileDirectory slash.
> >   							pathTokens := pathTokens
> >   										collect: [:s | s encodeForHTTP].
> >   							encodedPath := pathTokens
> >   										reduce: [:acc :each | acc , FileDirectory slash , each].
> >   							scriptName := (FileDirectory default uri resolveRelativeURI: encodedPath) asString]]]
> >   		ifFalse: [scriptName := ''].
> >   	scriptName isEmptyOrNil
> >   		ifTrue: [^ Preferences eToyFriendly
> >   				ifTrue: [self currentWorld addGlobalFlaps]].
> >   	loader := CodeLoader new.
> >   	loader
> >   		loadSourceFiles: (Array with: scriptName).
> >   	(scriptName asLowercase endsWith: '.pr')
> >   		ifTrue: [self installProjectFrom: loader]
> >   		ifFalse: [loader installSourceFiles]!
> > 
> > Item was changed:
> >   ----- Method: SmalltalkImage>>arguments (in category 'command line') -----
> >   arguments
> >   	"Answer an array with all the command line arguments.
> > + 	This does not include imagePath, documentPath nor any option.
> > + 	The '--' token on the command line indicates that remaining arguments should
> > + 	be passed to the image without interpretation, and should not be treated as e.g.
> > + 	specification of a start script." 
> > + 
> > - 	This does not include imagePath, documentPath nor any option."
> > - 	
> >   	"Smalltalk commandLine arguments"
> >   	
> > + 	| args |
> > - 	| args strm |
> >   	args := self rawArguments.
> > + 	(args includes: '--' )
> > + 		ifTrue: [ ^ args copyAfter: '--' ]
> > + 		ifFalse: [ | rs | rs := args readStream.
> > + 			rs next. "skip image name"
> > + 			self firstArgMightBeDocument
> > + 				ifTrue: [rs next "skip startup document name"].
> > + 			^ rs upToEnd ].
> > - 	(args includes: '--')
> > - 		ifTrue: [ ^args copyAfter: self imageArgumentsMarker ].
> > - 	strm := args readStream.
> > - 	strm atEnd ifFalse: [ strm next. "skip image name"
> > - 		(Preferences readDocumentAtStartup and: [ strm atEnd not ])
> > - 			ifTrue: [ strm next "skip startup document name" ]].
> > - 	^ strm upToEnd.
> >   !
> > 
> > Item was changed:
> >   ----- Method: SmalltalkImage>>documentPath (in category 'command line') -----
> >   documentPath
> >   	"Answer the absolute path of the document passed to the VM or nil if none."
> >   	"Smalltalk commandLine documentPath"
> > + 	^ (self getSystemAttribute: 2) ifNil: [ '' ]
> > - 	^ (self getSystemAttribute: 2)
> > - 		ifNotNil: [ :arg | arg = self imageArgumentsMarker
> > - 			ifTrue: [nil] ifFalse: [arg]].
> > - 
> >   !
> > 
> > Item was added:
> > + ----- Method: SmalltalkImage>>firstArgMightBeDocument (in category 'private') -----
> > + firstArgMightBeDocument
> > + 	"If the first argument begins with '-' then it is unlikely to be a document specification"
> > + 	^ (self documentPath beginsWith: '-') not
> > + !
> > 
> > Item was removed:
> > - ----- Method: SmalltalkImage>>imageArgumentsMarker (in category 'command line') -----
> > - imageArgumentsMarker
> > - 	"The '--' token on the command line indicates that remaining arguments should
> > - 	be passed to the image without interpretation, and should not be treated as e.g.
> > - 	specification of a start script." 
> > - 
> > - 	^ '--'!
> > 
> > 
> 


More information about the Squeak-dev mailing list