The Trunk: System-dtl.1204.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-dtl.1204.mcz

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

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

Name: System-dtl.1204
Author: dtl
Time: 18 December 2020, 9:57:54.912942 am
UUID: 47e43f60-e3fa-4174-ada2-b0b5eb6795d0
Ancestors: System-mt.1203

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.1203 ===============

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."
-
- ^ '--'!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-dtl.1204.mcz

David T. Lewis
On Fri, Dec 18, 2020 at 02:57:59PM +0000, [hidden email] wrote:

> David T. Lewis uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-dtl.1204.mcz
>
> ==================== Summary ====================
>
> Name: System-dtl.1204
> Author: dtl
> Time: 18 December 2020, 9:57:54.912942 am
> UUID: 47e43f60-e3fa-4174-ada2-b0b5eb6795d0
> Ancestors: System-mt.1203
>
> Enable removal of preference for 'Read document at startup'.
>

This replaces System-dtl.1197, which I have moved to the treated inbox.

Dave