The Trunk: System-dtl.1164.mcz

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

The Trunk: System-dtl.1164.mcz

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

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

Name: System-dtl.1164
Author: dtl
Time: 8 June 2020, 9:16:15.619687 pm
UUID: f4d402cd-389a-4600-abcb-6ba4486c07c4
Ancestors: System-mt.1163

Fix handling of the '--' command line token, and let command parameters be handled consistently by SmalltalkImage>>argumentAt:
Discussion at http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-June/209945.html

=============== Diff against System-mt.1163 ===============

Item was changed:
  ----- Method: SmalltalkImage>>argumentAt: (in category 'command line') -----
  argumentAt: argumentIndex
  "Answer the i-th argument of the command line, or nil if not so many argument."
+ ^ self arguments at: argumentIndex ifAbsent: [].
+ !
- ^ self getSystemAttribute:
- argumentIndex +
- (Preferences readDocumentAtStartup
- ifTrue: [ 2 ]
- ifFalse: [ 1 ])!

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."
 
  "Smalltalk commandLine arguments"
 
+ | args strm |
+ args := self rawArguments.
+ (args includes: '--')
+ ifTrue: [ ^args copyAfter: self imageArgumentsMarker ].
+ strm := args readStream.
+ strm atEnd ifFalse: [ strm next. "skip image name"
+ strm atEnd ifFalse: [ strm next "skip startup document name" ] ].
+ ^ strm upToEnd.
+ !
- ^Array streamContents: [:str |
- | arg i |
- i := 1.
- [i > 998 or: [(arg := self argumentAt: i) == nil]]
- whileFalse:
- [str nextPut: arg.
- i := i + 1]].!

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."
- "Answer the absolute path of the document passed to the vm or nil if none."
  "Smalltalk commandLine documentPath"
+ ^ (self getSystemAttribute: 2)
+ ifNotNil: [ :arg | arg = self imageArgumentsMarker
+ ifTrue: [nil] ifFalse: [arg]].
+
+ !
- ^ Preferences readDocumentAtStartup ifTrue: [ self getSystemAttribute: 2 ]!

Item was added:
+ ----- 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."
+
+ ^ '--'!

Item was added:
+ ----- Method: SmalltalkImage>>rawArguments (in category 'command line') -----
+ rawArguments
+ "Answer an array with all the command line arguments as delivered
+ from the VM. Any arguments for the VM itself will have been removed
+ (these are accessed with optionAt:)."
+
+ "Smalltalk commandLine rawArguments"
+
+ ^Array streamContents: [:str |
+ | arg i |
+ i := 1.
+ [i > 998 or: [(arg := self getSystemAttribute: i) == nil]]
+ whileFalse:
+ [str nextPut: arg.
+ i := i + 1]].!