#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Tue, 22 Jan 2019 14:02:04 +0100
changeset 23628 8a9baee8f42a
parent 23627 dde25738147a
child 23629 2709395b56a9
#QUALITY by cg class: Smalltalk class startup verbosity changed: #basicInitializeSystem #initializeVerboseFlags #mainStartup: #start
Smalltalk.st
--- a/Smalltalk.st	Mon Jan 21 18:02:29 2019 +0100
+++ b/Smalltalk.st	Tue Jan 22 14:02:04 2019 +0100
@@ -236,19 +236,21 @@
      right after startup, usually immediately followed by Smalltalk>>start.
 
      Notice:
-	this is NOT called when an image is restarted; in this
-	case the show starts in Smalltalk>>restart."
-
+        this is NOT called when an image is restarted; in this
+        case the show starts in Smalltalk>>restart."
+
+    'basicInitializeSystem' infoPrintCR.
+    
     OrderedCollection initialize.
 
     Smalltalk at:#Compiler put:ByteCodeCompiler.
     Compiler isNil ifTrue:[
-	"
-	 ByteCodeCompiler is not in the system (i.e. has not been linked in)
-	 this allows at least immediate evaluations for runtime systems without compiler
-	 NOTICE: a parser is always needed, otherwise we cannot read resource files etc.
-	"
-	Smalltalk at:#Compiler put:Parser
+        "
+         ByteCodeCompiler is not in the system (i.e. has not been linked in)
+         this allows at least immediate evaluations for runtime systems without compiler
+         NOTICE: a parser is always needed, otherwise we cannot read resource files etc.
+        "
+        Smalltalk at:#Compiler put:Parser
     ].
 
     "/
@@ -287,7 +289,7 @@
     "/ in case, someone needs the objectFileLoader early
     "/
     ObjectFileLoader notNil ifTrue:[
-	ObjectFileLoader initialize.
+        ObjectFileLoader initialize.
     ].
 
     "/
@@ -304,7 +306,7 @@
     "/ flush them here, so they are reread in any case.
     "/ required for some apps, for example to show the menu correctly (see launcher's help menu)
     ApplicationModel notNil ifTrue:[
-	ApplicationModel flushAllClassResources.
+        ApplicationModel flushAllClassResources.
     ].
 
     "/
@@ -317,6 +319,7 @@
     "Modified: / 05-12-2006 / 21:48:58 / cg"
     "Modified: / 24-10-2012 / 18:45:15 / sr"
     "Modified: / 27-02-2017 / 20:39:14 / stefan"
+    "Modified: / 22-01-2019 / 12:55:40 / Claus Gittinger"
 !
 
 initGlobalsFromEnvironment
@@ -699,102 +702,103 @@
     |idx|
 
     StandAlone ifTrue:[
-	InfoPrinting := false.
-	ObjectMemory infoPrinting:false.
-	IgnoreAssertions := true.
+        InfoPrinting := false.
+        ObjectMemory infoPrinting:false.
+        IgnoreAssertions := true.
     ] ifFalse:[
-	IgnoreAssertions := false.
+        IgnoreAssertions := false.
     ].
 
     (idx := CommandLineArguments indexOf:'--ignoreHalt') ~~ 0 ifTrue:[
-	IgnoreHalt := true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        IgnoreHalt := true.
     ].
     (idx := CommandLineArguments indexOf:'--noIgnoreHalt') ~~ 0 ifTrue:[
-	IgnoreHalt := false.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        IgnoreHalt := false.
     ].
     (idx := CommandLineArguments indexOf:'--ignoreAssert') ~~ 0 ifTrue:[
-	IgnoreAssertions := true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        IgnoreAssertions := true.
     ].
     (idx := CommandLineArguments indexOf:'--noIgnoreAssert') ~~ 0 ifTrue:[
-	IgnoreAssertions := false.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        IgnoreAssertions := false.
     ].
     (idx := CommandLineArguments indexOf:'--assert') ~~ 0 ifTrue:[
-	IgnoreAssertions := false.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        IgnoreAssertions := false.
     ].
     (idx := CommandLineArguments indexOf:'--silentStartup') ~~ 0 ifTrue:[
-	SilentLoading := true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        SilentLoading := true.
     ].
     (idx := CommandLineArguments indexOf:'--verboseLoading') ~~ 0 ifTrue:[
-	VerboseLoading := true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        VerboseLoading := true.
     ].
     (idx := CommandLineArguments indexOf:'--verboseStartup') ~~ 0 ifTrue:[
-	VerboseLoading := true.
-	VerboseStartup := true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        VerboseLoading := true.
+        VerboseStartup := true.
     ].
 
     "/ reinterpret those, in case given after the VM options.
     (idx := CommandLineArguments indexOf:'--debugPrint') ~~ 0 ifTrue:[
-	ObjectMemory debugPrinting:true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        ObjectMemory debugPrinting:true.
     ].
     (idx := CommandLineArguments indexOf:'--infoPrint') ~~ 0 ifTrue:[
-	ObjectMemory infoPrinting:true.
-	CommandLineArguments removeIndex:idx
+        CommandLineArguments removeIndex:idx.
+        ObjectMemory infoPrinting:true.
     ].
 
     (idx := CommandLineArguments indexOf:'--verbose') ~~ 0 ifTrue:[
-	Object infoPrinting:true.
-	Verbose := true.
-	VerboseLoading := true.
-	VerboseStartup := true.
-	Logger notNil ifTrue:[
-	    Logger loggingThreshold: Logger severityALL.
-	].
-	CommandLineArguments removeIndex:idx.
+        CommandLineArguments removeIndex:idx.
+        Object infoPrinting:true.
+        Verbose := true.
+        VerboseLoading := true.
+        VerboseStartup := true.
+        Logger notNil ifTrue:[
+            Logger loggingThreshold: Logger severityALL.
+        ].
     ].
 
     Silent := false.
     (idx := CommandLineArguments indexOf:'--silent') ~~ 0 ifTrue:[
-	CommandLineArguments removeIndex:idx.
-	Silent := SilentLoading := true.
-	Object infoPrinting:false.
-	ObjectMemory infoPrinting:false.
-	ObjectMemory debugPrinting:false.
-	Verbose := VerboseLoading := VerboseStartup := false.
-	Logger notNil ifTrue:[
-	    Logger loggingThreshold: Logger severityNONE
-	].
+        CommandLineArguments removeIndex:idx.
+        Silent := SilentLoading := true.
+        Object infoPrinting:false.
+        ObjectMemory infoPrinting:false.
+        ObjectMemory debugPrinting:false.
+        Verbose := VerboseLoading := VerboseStartup := false.
+        Logger notNil ifTrue:[
+            Logger loggingThreshold: Logger severityNONE
+        ].
     ].
 
     idx := CommandLineArguments indexOf:'--debug'.
     Debugging := (idx ~~ 0).
 
     StandAlone ifTrue:[
-	DebuggingStandAlone := Debugging.
-	DebuggingStandAlone ifTrue:[
-	    Inspector := MiniInspector.
-	    Debugger := MiniDebugger.
-	    IgnoreAssertions := false.
-	].
+        DebuggingStandAlone := Debugging.
+        DebuggingStandAlone ifTrue:[
+            Inspector := MiniInspector.
+            Debugger := MiniDebugger.
+            IgnoreAssertions := false.
+        ].
     ] ifFalse:[
-	"/
-	"/ define low-level debugging tools - graphical classes are not prepared yet
-	"/ to handle things.
-	"/ This will bring us into the MiniDebugger when an error occurs during startup.
-	"/
-	Inspector := MiniInspector.
-	Debugger := MiniDebugger.
+        "/
+        "/ define low-level debugging tools - graphical classes are not prepared yet
+        "/ to handle things.
+        "/ This will bring us into the MiniDebugger when an error occurs during startup.
+        "/
+        Inspector := MiniInspector.
+        Debugger := MiniDebugger.
     ].
 
     "Modified: / 12-10-2017 / 17:48:11 / cg"
+    "Modified: / 22-01-2019 / 12:59:36 / Claus Gittinger"
 !
 
 isInitialized
@@ -3991,47 +3995,51 @@
 
     |process imageName thisIsARestart idx|
 
+    VerboseStartup ifTrue:['mainStartup...' infoPrintCR].
+
     imageName := ObjectMemory imageName.
     thisIsARestart := imageName notNil.
 
     true "graphicalMode" ifTrue:[
-	Display isNil ifTrue:[
-	    (StartupClass notNil
-	    and:[ (StartupClass perform:#isHeadless ifNotUnderstood:false) ]) ifFalse:[
-		self openDisplay.
-	    ].
-	].
+        Display isNil ifTrue:[
+            (StartupClass notNil
+            and:[ (StartupClass perform:#isHeadless ifNotUnderstood:false) ]) ifFalse:[
+                self openDisplay.
+            ].
+        ].
     ].
 
     StandAlone ifFalse:[
-	"
-	 enable the graphical debugger/inspector
-	 (they could have been (re)defined as autoloaded in the patches file)
-	"
-	self initStandardTools.
+        "
+         enable the graphical debugger/inspector
+         (they could have been (re)defined as autoloaded in the patches file)
+        "
+        VerboseStartup ifTrue:['initStandardTools...' infoPrintCR].
+        self initStandardTools.
     ].
 
     "
      if there is a display, start its event dispatcher
     "
     Display notNil ifTrue:[
-	Display deviceIOTimeoutErrorSignal handlerBlock:[:ex |
-	    SaveEmergencyImage == true ifTrue:[
-		'Display [warning]: broken display connection - emergency save in ''crash.img''.' infoPrintCR.
-		ObjectMemory primSnapShotOn:'crash.img'.
-	    ].
-	    'Display [warning]: broken display connection - exit.' infoPrintCR.
-	    self exit:11.
-	].
-	Display startDispatch.
+        Display deviceIOTimeoutErrorSignal handlerBlock:[:ex |
+            SaveEmergencyImage == true ifTrue:[
+                'Display [warning]: broken display connection - emergency save in ''crash.img''.' infoPrintCR.
+                ObjectMemory primSnapShotOn:'crash.img'.
+            ].
+            'Display [warning]: broken display connection - exit.' infoPrintCR.
+            self exit:11.
+        ].
+        VerboseStartup ifTrue:['display-dispatch...' infoPrintCR].
+        Display startDispatch.
     ].
 
     idx := CommandLineArguments indexOf:'--browserWindow:'.
     IsPlugin := (idx ~~ 0).
     IsPlugin ifTrue:[
-	'Smalltalk [info]: startup browser window...' infoPrintCR.
-	self browserWindowStartup.
-	"/ not reached
+        'Smalltalk [info]: startup browser window...' infoPrintCR.
+        self browserWindowStartup.
+        "/ not reached
     ].
 
     Initializing := false.
@@ -4042,49 +4050,50 @@
     "/ Therefore, it is now done by an extra user-process.
 
     process := [
-	'Smalltalk [info]: startup process 1 active.' infoPrintCR.
-	StartBlocks notNil ifTrue:[
-	    self executeStartBlocks.
-	    StartBlocks := nil.
-	].
-	ImageStartBlocks notNil ifTrue:[
-	    'Smalltalk [info]: execute imageStartBlocks...' infoPrintCR.
-	    ImageStartBlocks do:[:aBlock|
-		aBlock value
-	    ].
-	].
-	StandAlone ifFalse:[
-	    (SilentLoading == true) ifFalse:[   "i.e. undefined counts as false"
-		thisIsARestart ifTrue:[
-		    Transcript cr.
-		    Transcript showCR:('Smalltalk restarted from:'
-					, imageName
-					, ' (saved '
-					, ObjectMemory imageSaveTime printString
-					, ')' ).
-		] ifFalse:[
-		    Transcript showCR:(self hello).
-		    Transcript showCR:(self copyrightString).
-		].
-		Transcript cr.
-	    ].
-
-	    DemoMode==true ifTrue:[
-		Transcript showCR:'*** Restricted use:                              ***'.
-		Transcript showCR:'*** This program may be used for education only. ***'.
-		Transcript showCR:'*** Please read the files COPYRIGHT and LICENSE  ***'.
-		Transcript showCR:'*** for more details.                            ***'.
-		Transcript cr.
-	    ].
-	].
-
-	thisIsARestart ifTrue:[
-	    "/
-	    "/ the final late notification - users can now assume that
-	    "/ views, forms etc. have been recreated.
-
-	    ObjectMemory changed:#returnFromSnapshot.
-	]
+        VerboseStartup ifTrue:[ 'Smalltalk [info]: startup process 1 active.' infoPrintCR].
+        StartBlocks notNil ifTrue:[
+            self executeStartBlocks.
+            StartBlocks := nil.
+        ].
+        ImageStartBlocks notNil ifTrue:[
+            VerboseStartup ifTrue:[ 'Smalltalk [info]: execute imageStartBlocks...' infoPrintCR].
+            ImageStartBlocks do:[:aBlock|
+                VerboseStartup ifTrue:[ ('Smalltalk [info]: startBlock: %1...' bindWith:aBlock) infoPrintCR].
+                aBlock value
+            ].
+        ].
+        StandAlone ifFalse:[
+            (SilentLoading == true) ifFalse:[   "i.e. undefined counts as false"
+                thisIsARestart ifTrue:[
+                    Transcript cr.
+                    Transcript showCR:('Smalltalk restarted from:'
+                                        , imageName
+                                        , ' (saved '
+                                        , ObjectMemory imageSaveTime printString
+                                        , ')' ).
+                ] ifFalse:[
+                    Transcript showCR:(self hello).
+                    Transcript showCR:(self copyrightString).
+                ].
+                Transcript cr.
+            ].
+
+            DemoMode==true ifTrue:[
+                Transcript showCR:'*** Restricted use:                              ***'.
+                Transcript showCR:'*** This program may be used for education only. ***'.
+                Transcript showCR:'*** Please read the files COPYRIGHT and LICENSE  ***'.
+                Transcript showCR:'*** for more details.                            ***'.
+                Transcript cr.
+            ].
+        ].
+
+        thisIsARestart ifTrue:[
+            "/
+            "/ the final late notification - users can now assume that
+            "/ views, forms etc. have been recreated.
+
+            ObjectMemory changed:#returnFromSnapshot.
+        ]
 
     ] newProcess.
 
@@ -4101,63 +4110,63 @@
     "/ message.
 
     (StartupClass notNil and:[StartupSelector notNil]) ifTrue:[
-	"
-	 allow more customization by reading an image specific rc-file
-	"
-	thisIsARestart ifTrue:[
-	    (imageName asFilename hasSuffix:'img') ifTrue:[
-		imageName := imageName copyButLast:4
-	    ].
-	    self fileIn:(imageName , '.rc')
-	].
-
-	Display notNil ifTrue:[
-	    Display exitOnLastClose:true.
-	].
-	Processor exitWhenNoMoreUserProcesses:true.
-
-	process := [
-	    'Smalltalk [info]: startup process 2 active.' infoPrintCR.
-	    StandAlone ifTrue:[
-		AbortOperationRequest handle:[:ex |
-		    'Smalltalk [info]: aborted - exit.' infoPrintCR.
-		    OperatingSystem exit:1
-		] do:[
-		    ('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (1)') infoPrintCR.
-		    StartupClass perform:StartupSelector withArguments:StartupArguments.
-		]
-	    ] ifFalse:[
-		('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (2)') infoPrintCR.
-		StartupClass perform:StartupSelector withArguments:StartupArguments.
-	    ].
-
-	    "/
-	    "/ non-GUI apps exit after the startup;
-	    "/ assume that GUI apps have created & opened some view ...
-	    "/
-	    Display isNil ifTrue:[
-		'Smalltalk [info]: no Display - exit.' infoPrintCR.
-		Smalltalk exit:11.
-	    ].
+        "
+         allow more customization by reading an image specific rc-file
+        "
+        thisIsARestart ifTrue:[
+            (imageName asFilename hasSuffix:'img') ifTrue:[
+                imageName := imageName copyButLast:4
+            ].
+            self fileIn:(imageName , '.rc')
+        ].
+
+        Display notNil ifTrue:[
+            Display exitOnLastClose:true.
+        ].
+        Processor exitWhenNoMoreUserProcesses:true.
+
+        process := [
+            'Smalltalk [info]: startup process 2 active.' infoPrintCR.
+            StandAlone ifTrue:[
+                AbortOperationRequest handle:[:ex |
+                    'Smalltalk [info]: aborted - exit.' infoPrintCR.
+                    OperatingSystem exit:1
+                ] do:[
+                    ('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (1)') infoPrintCR.
+                    StartupClass perform:StartupSelector withArguments:StartupArguments.
+                ]
+            ] ifFalse:[
+                ('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (2)') infoPrintCR.
+                StartupClass perform:StartupSelector withArguments:StartupArguments.
+            ].
+
+            "/
+            "/ non-GUI apps exit after the startup;
+            "/ assume that GUI apps have created & opened some view ...
+            "/
+            Display isNil ifTrue:[
+                'Smalltalk [info]: no Display - exit.' infoPrintCR.
+                Smalltalk exit:11.
+            ].
 "/            "/
 "/            "/ GUI apps exit after the last user process has finished
 "/            "/
 "/            Display exitOnLastClose:true.
-	    Processor exitWhenNoMoreUserProcesses:true.
-	] newProcess.
-	process priority:(Processor userSchedulingPriority).
-	process name:'main'.
-	process beGroupLeader.
-	process resume.
-	process := nil.    "do not refer to process"
+            Processor exitWhenNoMoreUserProcesses:true.
+        ] newProcess.
+        process priority:(Processor userSchedulingPriority).
+        process name:'main'.
+        process beGroupLeader.
+        process resume.
+        process := nil.    "do not refer to process"
     ].
 
     StandAlone ifTrue:[
-	Display notNil ifTrue:[
-	    FlyByHelp notNil ifTrue:[
-		FlyByHelp start
-	    ].
-	].
+        Display notNil ifTrue:[
+            FlyByHelp notNil ifTrue:[
+                FlyByHelp start
+            ].
+        ].
     ].
 
 "/    Display notNil ifTrue:[
@@ -4174,14 +4183,14 @@
      or:[HeadlessOperation
      or:[StandAlone]]]
     ) ifTrue:[
-	Processor exitWhenNoMoreUserProcesses:true.
-	Processor dispatchLoop.
-	"done - the last process finished"
-	'Smalltalk [info]: last process finished - exit.' infoPrintCR.
+        Processor exitWhenNoMoreUserProcesses:true.
+        Processor dispatchLoop.
+        "done - the last process finished"
+        'Smalltalk [info]: last process finished - exit.' infoPrintCR.
     ] ifFalse:[
-	StandAlone ifFalse:[
-	    self readEvalPrintLoop
-	]
+        StandAlone ifFalse:[
+            self readEvalPrintLoop
+        ]
     ].
 
     self exit
@@ -4189,6 +4198,7 @@
     "Created: / 18-07-1996 / 21:07:39 / cg"
     "Modified: / 09-09-1996 / 17:42:50 / stefan"
     "Modified: / 28-02-2017 / 10:59:43 / cg"
+    "Modified: / 22-01-2019 / 14:00:22 / Claus Gittinger"
 !
 
 openDisplay
@@ -4509,453 +4519,457 @@
      (i.e. script/repl/eval or full blown IDE).
      Also handles --load and various debug options.
      Caveat:
-	this has become too complicated and desperately needs a rewrite.
+        this has become too complicated and desperately needs a rewrite.
 
      Also:
-	Be very careful when changing things here;
-	especially be careful to ensure that the scripting options are robust against any
-	missing packages; so the error handlers should not depend on any stream, logger etc. features.
+        Be very careful when changing things here;
+        especially be careful to ensure that the scripting options are robust against any
+        missing packages; so the error handlers should not depend on any stream, logger etc. features.
      "
 
     |idx graphicalMode arg didReadRCFile keepSplashWindow|
 
+    VerboseStartup ifTrue:['start...' infoPrintCR].
+
     graphicalMode := Smalltalk isSmalltalkDevelopmentSystem.
     Initializing := true.
 
     keepSplashWindow := StartupClass perform:#keepSplashWindowOpen ifNotUnderstood:[false].
 
+    "/ remove possibly leftover --debug arg (not removed in initVerboseFlags, for whatever reason)
     idx := CommandLineArguments indexOf:'--debug'.
     (idx ~~ 0) ifTrue:[
-	CommandLineArguments removeAtIndex:idx.
+        CommandLineArguments removeAtIndex:idx.
     ].
 
     "
      while reading patches- and rc-file, do not add things into change-file
     "
     Class withoutUpdatingChangesDo:[
-	|commandFiles rcFile defaultRC prevCatchSetting
-	 isEval isPrint isFilter isRepl isRunMain idxFileArg process|
-
-	isEval := isPrint := isFilter := isRepl := isRunMain := false.
-	didReadRCFile := false.
-
-	StandAlone ifFalse:[
-	    "/ self initializeVerboseFlags.
-
-	    "/
-	    "/ look for any '-q', '-e', '-l' or '-f' command line arguments
-	    "/ and handle them;
-	    "/ read startup and patches file
-	    "/
-	    idx := CommandLineArguments indexOfAny:#('-R' '--repl').
-	    isRepl := IsRepl := (idx ~~ 0).
-
-	    idx := CommandLineArguments indexOfAny:#('-q' '--silent').
-	    idx ~~ 0 ifTrue:[
-		Object infoPrinting:false.
-		ObjectMemory infoPrinting:false.
-		CommandLineArguments removeAtIndex:idx.
-		SilentLoading := true.
-	    ].
-
-	    [
-		idx := CommandLineArguments indexOfAny:#('-pp' '--packagePath').
-		idx ~~ 0
-	    ] whileTrue:[
-		arg := CommandLineArguments at:idx + 1.
-		CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
-		(arg asCollectionOfSubstringsSeparatedByAny:',;') do:[:each |
-		    self packagePath addLast:each.
-		    VerboseStartup ifTrue:[
-			('Smalltalk [info]: add to packagePath: "', arg, '".') infoPrintCR.
-		    ].
-		].
-	    ].
-
-	    [
-		idx := CommandLineArguments indexOfAny:#('-l' '--load').
-		idx ~~ 0
-	    ] whileTrue:[
-		arg := CommandLineArguments at:idx + 1.
-		CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
-		Smalltalk silentlyLoadingDo:[
-		    (arg asCollectionOfSubstringsSeparatedByAny:',;') do:[:each |
-			each asFilename exists ifTrue:[
-			    (VerboseStartup | VerboseLoading) ifTrue:[
-				('Smalltalk [info]: loading file: "', each, '".') infoPrintCR.
-			    ].
-			    Smalltalk fileIn:each
-			] ifFalse:[
-			    (VerboseStartup | VerboseLoading) ifTrue:[
-				('Smalltalk [info]: loading package: "', each, '".') infoPrintCR.
-			    ].
-			    Smalltalk loadPackage:each
-			].
-		    ].
-		].
-	    ].
-
-	    "/ look for a '-e filename' or '--execute filename' or '--script filename' argument
-	    "/ this will force fileIn of filename only, no standard startup.
-
-	    idx := CommandLineArguments indexOfAny:#('-e' '--execute' '--script').
-	    idx ~~ 0 ifTrue:[
-		SilentLoading := true.
-		CommandName := arg := CommandLineArguments at:idx + 1.
-
-		CommandLineArguments
-		    removeAtIndex:idx+1; removeAtIndex:idx.
-
-		self startSchedulerAndBackgroundCollector.
-		keepSplashWindow ifFalse:[ self hideSplashWindow ].
-		Initializing := false.
-
-		process := [
-		    Processor exitWhenNoMoreUserProcesses:true.
-
-		    "/ set workspace variables
-		    self defineCommandLineAsWorkspaceVariablesForScripts.
-
-		    "/ provide a Display, if needed
-		    self providingDisplayDo:[
-			VerboseStartup ifTrue:[
-			    ('Smalltalk [info]: reading script from: "', arg, '".') infoPrintCR.
-			].
-			NoHandlerError handle:[:ex |
-			    Debugging == true ifTrue:[
-				MiniDebugger enterException:ex.
-			    ] ifFalse:[
-				Silent ifFalse:[
-				    'Smalltalk [error]: ' _errorPrint. ex exception description _errorPrintCR.
-				].
-				(VerboseStartup or:[ObjectMemory debugPrinting]) ifTrue:[
-				    ex suspendedContext fullPrintAll.
-				].
-				self exit:1.
-			    ].
-			    self exit:1.
-			    "/ ex reject.
-			] do:[
-			    UserInterrupt handle:[:ex |
-				Debugging == true ifTrue:[
-				    'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR.
-				    "/ thisContext fullPrintAll.
-				    MiniDebugger enterException:ex.
-				    ex proceed.
-				].
-				Silent ifFalse:[ 'user interrupt.' errorPrintCR ].
-				self exit:128+(OperatingSystem sigINT).
-			    ] do:[
-				|cmdStream result|
-
-				arg = '-' ifTrue:[
-				    cmdStream := Stdin.
-				] ifFalse:[
-				    IsSTScript := true.
-				    cmdStream := arg asFilename readStream.
-				].
-				result := [
-				    self fileInStream:cmdStream
-					   lazy:nil
-					   silent:self verbose not
-					   logged:false
-					   addPath:nil
-				] ensure:[
-				    IsSTScript ifTrue:[
-					"/ do not close Stdin
-					cmdStream close.
-				    ].
-				].
-				result ifFalse:[
-				    self exit:1.
-				].
-			    ].
-			].
-		    ].
-
-		    "/ after the script, if Screen has been opened and there are any open windows,
-		    "/ then do not exit
+        |commandFiles rcFile defaultRC prevCatchSetting
+         isEval isPrint isFilter isRepl isRunMain idxFileArg process|
+
+        isEval := isPrint := isFilter := isRepl := isRunMain := false.
+        didReadRCFile := false.
+
+        StandAlone ifFalse:[
+            "/ self initializeVerboseFlags.
+
+            "/
+            "/ look for any '-q', '-e', '-l' or '-f' command line arguments
+            "/ and handle them;
+            "/ read startup and patches file
+            "/
+            idx := CommandLineArguments indexOfAny:#('-R' '--repl').
+            isRepl := IsRepl := (idx ~~ 0).
+
+            idx := CommandLineArguments indexOfAny:#('-q' '--silent').
+            idx ~~ 0 ifTrue:[
+                Object infoPrinting:false.
+                ObjectMemory infoPrinting:false.
+                CommandLineArguments removeAtIndex:idx.
+                SilentLoading := true.
+            ].
+
+            [
+                idx := CommandLineArguments indexOfAny:#('-pp' '--packagePath').
+                idx ~~ 0
+            ] whileTrue:[
+                arg := CommandLineArguments at:idx + 1.
+                CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
+                (arg asCollectionOfSubstringsSeparatedByAny:',;') do:[:each |
+                    self packagePath addLast:each.
+                    VerboseStartup ifTrue:[
+                        ('Smalltalk [info]: add to packagePath: "', arg, '".') infoPrintCR.
+                    ].
+                ].
+            ].
+
+            [
+                idx := CommandLineArguments indexOfAny:#('-l' '--load').
+                idx ~~ 0
+            ] whileTrue:[
+                arg := CommandLineArguments at:idx + 1.
+                CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx.
+                Smalltalk silentlyLoadingDo:[
+                    (arg asCollectionOfSubstringsSeparatedByAny:',;') do:[:each |
+                        each asFilename exists ifTrue:[
+                            (VerboseStartup | VerboseLoading) ifTrue:[
+                                ('Smalltalk [info]: loading file: "', each, '".') infoPrintCR.
+                            ].
+                            Smalltalk fileIn:each
+                        ] ifFalse:[
+                            (VerboseStartup | VerboseLoading) ifTrue:[
+                                ('Smalltalk [info]: loading package: "', each, '".') infoPrintCR.
+                            ].
+                            Smalltalk loadPackage:each
+                        ].
+                    ].
+                ].
+            ].
+
+            "/ look for a '-e filename' or '--execute filename' or '--script filename' argument
+            "/ this will force fileIn of filename only, no standard startup.
+
+            idx := CommandLineArguments indexOfAny:#('-e' '--execute' '--script').
+            idx ~~ 0 ifTrue:[
+                SilentLoading := true.
+                CommandName := arg := CommandLineArguments at:idx + 1.
+
+                CommandLineArguments
+                    removeAtIndex:idx+1; removeAtIndex:idx.
+
+                self startSchedulerAndBackgroundCollector.
+                keepSplashWindow ifFalse:[ self hideSplashWindow ].
+                Initializing := false.
+
+                process := [
+                    Processor exitWhenNoMoreUserProcesses:true.
+
+                    "/ set workspace variables
+                    self defineCommandLineAsWorkspaceVariablesForScripts.
+
+                    "/ provide a Display, if needed
+                    self providingDisplayDo:[
+                        VerboseStartup ifTrue:[
+                            ('Smalltalk [info]: reading script from: "', arg, '".') infoPrintCR.
+                        ].
+                        NoHandlerError handle:[:ex |
+                            Debugging == true ifTrue:[
+                                MiniDebugger enterException:ex.
+                            ] ifFalse:[
+                                Silent ifFalse:[
+                                    'Smalltalk [error]: ' _errorPrint. ex exception description _errorPrintCR.
+                                ].
+                                (VerboseStartup or:[ObjectMemory debugPrinting]) ifTrue:[
+                                    ex suspendedContext fullPrintAll.
+                                ].
+                                self exit:1.
+                            ].
+                            self exit:1.
+                            "/ ex reject.
+                        ] do:[
+                            UserInterrupt handle:[:ex |
+                                Debugging == true ifTrue:[
+                                    'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR.
+                                    "/ thisContext fullPrintAll.
+                                    MiniDebugger enterException:ex.
+                                    ex proceed.
+                                ].
+                                Silent ifFalse:[ 'user interrupt.' errorPrintCR ].
+                                self exit:128+(OperatingSystem sigINT).
+                            ] do:[
+                                |cmdStream result|
+
+                                arg = '-' ifTrue:[
+                                    cmdStream := Stdin.
+                                ] ifFalse:[
+                                    IsSTScript := true.
+                                    cmdStream := arg asFilename readStream.
+                                ].
+                                result := [
+                                    self fileInStream:cmdStream
+                                           lazy:nil
+                                           silent:self verbose not
+                                           logged:false
+                                           addPath:nil
+                                ] ensure:[
+                                    IsSTScript ifTrue:[
+                                        "/ do not close Stdin
+                                        cmdStream close.
+                                    ].
+                                ].
+                                result ifFalse:[
+                                    self exit:1.
+                                ].
+                            ].
+                        ].
+                    ].
+
+                    "/ after the script, if Screen has been opened and there are any open windows,
+                    "/ then do not exit
 false ifTrue:[
-		    Display notNil ifTrue:[
-			Processor exitWhenNoMoreUserProcesses:true.
-			"/ Display exitOnLastClose:true.
-			"/ Display checkForEndOfDispatch.
-		    ] ifFalse:[
-			self exit.
-		    ].
+                    Display notNil ifTrue:[
+                        Processor exitWhenNoMoreUserProcesses:true.
+                        "/ Display exitOnLastClose:true.
+                        "/ Display checkForEndOfDispatch.
+                    ] ifFalse:[
+                        self exit.
+                    ].
 ].
-		] newProcess.
-		process priority:(Processor userSchedulingPriority).
-		process name:'main'.
-		process beGroupLeader.
-		process resume.
-
-		Processor dispatchLoop.
-		self exit
-	    ].
-
-	    "look for a '-f filename' or '--file filename' argument
-	     if scripting, these are loaded before -P, -E or -R action.
-	     if not scripting, this will force evaluation of filename instead of smalltalk.rc"
-	    [
-		idxFileArg := CommandLineArguments indexOfAny:#('-f' '--file').
-		(idxFileArg ~~ 0)
-	    ] whileTrue:[
-		commandFiles isNil ifTrue:[ commandFiles := OrderedCollection new ].
-		commandFiles add:(CommandLineArguments at:idxFileArg+1).
-		CommandLineArguments removeAtIndex:idxFileArg+1; removeAtIndex:idxFileArg.
-	    ].
-
-	    "/ look for a '-E expr' or '--eval expr' argument (-P or --print to print the result of evaluation)
-	    "/ or -F/--filter or a '--repl' argument
-	    "/ E, P and F this will force evaluation of expr only, no standard startup
-	    "/ repl go into an interactive loop.
-	    idx := CommandLineArguments indexOfAny:#('-E' '--eval').
-	    (isEval := (idx ~~ 0)) ifFalse:[
-		idx := CommandLineArguments indexOfAny:#('-P' '--print').
-		(isPrint := (idx ~~ 0)) ifFalse:[
-		    idx := CommandLineArguments indexOfAny:#('-F' '--filter').
-		    (isFilter := (idx ~~ 0)) ifFalse:[
-			idx := CommandLineArguments indexOfAny:#('-R' '--repl').
-			(isRepl := (idx ~~ 0)) ifFalse:[
-			    idx := CommandLineArguments indexOfAny:#('--run').
-			    isRunMain := (idx ~~ 0)
-			].
-		    ].
-		].
-	    ].
-
-	    (isEval | isPrint | isFilter | isRepl | isRunMain) ifTrue:[
-		|args|
-
-		VerboseStartup ifTrue:[
-		    ('Smalltalk [info]: eval/filter/print or repl') infoPrintCR.
-		].
-		isRepl ifFalse:[
-		    CommandLineArguments size <= idx ifTrue:[
-			StandAlone := true.
-			self exitWithErrorMessage:'missing argument after -E/-P/-F/--run.'.
-		    ].
-		    isFilter ifTrue:[
-			args := CommandLineArguments copyFrom:idx + 1.
-			CommandLineArguments removeFromIndex:idx+1.
-			VerboseStartup ifTrue:[
-			    ('Smalltalk [info]: filter expression(s): ') infoPrint.
-			    args infoPrintCR.
-			].
-		    ] ifFalse:[
-			arg := CommandLineArguments at:idx + 1.
-			CommandLineArguments removeAtIndex:idx+1.
-			VerboseStartup ifTrue:[
-			    ('Smalltalk [info]: eval expression: ') infoPrint.
-			    arg infoPrintCR.
-			].
-		    ].
-		].
-		CommandLineArguments removeAtIndex:idx.
-
-		self startSchedulerAndBackgroundCollector.
-
-		keepSplashWindow ifFalse:[ self hideSplashWindow ].
-		Initializing := false.
-
-		"/ set workspace variables
-		self defineCommandLineAsWorkspaceVariablesForScripts.
-
-		"/ all of the above allow for a -f file to be loaded before any other action
-		(commandFiles notEmptyOrNil) ifTrue:[
-		    commandFiles do:[:commandFile |
-			(VerboseStartup | VerboseLoading) ifTrue:[
-			    ('Smalltalk [info]: reading command file from: "', commandFile, '".') infoPrintCR.
-			].
-			Smalltalk silentlyLoadingDo:[
-			    (self secureFileIn:commandFile) ifFalse:[
-				StandAlone := true.
-				self exitWithErrorMessage:('"', commandFile, '" not found.').
-			    ]
-			]
-		    ]
-		].
-
-		isRepl ifFalse:[
-		    Debugging == true ifFalse:[
-			"/ remove the Debugger
-			Debugger := nil.
-		    ].
-		].
-
-		process := [
-		    self providingDisplayDo:[
-			isRepl ifTrue:[
-			    Processor exitWhenNoMoreUserProcesses:false.
-			    Processor activeProcess name:'repl'.
-			    self readEvalPrintLoop.
-			    self exit.
-			].
-
-			Processor exitWhenNoMoreUserProcesses:true.
-
-			NoHandlerError handle:[:ex |
-			    Debugging == true ifTrue:[
-				MiniDebugger enterException:ex.
-			    ] ifFalse:[
-				Silent ifFalse:[
-				    'Smalltalk [error]: ' _errorPrint. ex description _errorPrintCR.
-				].
-				(VerboseStartup or:[ObjectMemory debugPrinting]) ifTrue:[
-				    ex suspendedContext fullPrintAll.
-				].
-				self exit:1.
-			    ].
-			    self exit:1.
-			    "/ ex reject.
-			] do:[
-			    UserInterrupt handle:[:ex |
-				Debugging == true ifTrue:[
-				    'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR.
-				    "/ thisContext fullPrintAll.
-				    MiniDebugger enterException:ex.
-				    ex proceed.
-				].
-				Silent ifFalse:[ 'user interrupt.' errorPrintCR ].
-				self exit:128+(OperatingSystem sigINT).
-			    ] do:[
-				|filterCode filterStart filterEnd|
-
-				isFilter ifTrue:[
-				    "/ --filter - apply code to each input line.
-				    "/ compile code only once
-				    (args size == 1) ifTrue:[
-					VerboseStartup ifTrue:[
-					    'Smalltalk [info]: filter 1-arg' infoPrintCR.
-					].
-					filterCode := args at:1.
-				    ] ifFalse:[
-					(args size == 3) ifTrue:[
-					    VerboseStartup ifTrue:[
-						'Smalltalk [info]: filter 3-arg' infoPrintCR.
-					    ].
-					    filterStart := args at:1.
-					    filterCode := args at:2.
-					    filterEnd := args at:3.
-					] ifFalse:[
-					    StandAlone := true.
-					    self exitWithErrorMessage:'--filter must be followed by 1 or 3 expression arg(s)'
-					].
-				    ].
-				    filterStart notEmptyOrNil ifTrue:[
-					VerboseStartup ifTrue:[
-					    ('Smalltalk [info]: eval: "', filterStart, '"...') infoPrintCR.
-					].
-					Compiler evaluate:filterStart notifying:(EvalScriptingErrorHandler new source:filterStart)
-				    ].
-				    VerboseStartup ifTrue:[
-					('Smalltalk [info]: compile: "', filterCode, '"...') infoPrintCR.
-				    ].
-				    Compiler
-					compile:'doIt:line ',filterCode
-					forClass:String
-					notifying:(EvalScriptingErrorHandler new source:filterCode).
-
-				    [Stdin atEnd] whileFalse:[
-					|line|
-
-					line := Stdin nextLine.
-					line doIt:line.
-				    ].
-				    filterEnd notEmptyOrNil ifTrue:[
-					VerboseStartup ifTrue:[
-					    ('Smalltalk [info]: eval: "', filterEnd, '"...') infoPrintCR.
-					].
-					Compiler evaluate:filterEnd notifying:(EvalScriptingErrorHandler new source:filterEnd)
-				    ].
-				] ifFalse:[
-				    (isPrint | isEval) ifTrue:[
-					"/ --print or --eval
-					|rslt|
-
-					rslt := Parser new
-						    evaluate:arg
-						    notifying:(EvalScriptingErrorHandler new source:arg)
-						    compile:true.
-					isPrint ifTrue:[
-					    rslt printCR.
-					].
-				    ] ifFalse:[
-					"/ --run <className>
-					|className class|
-
-					className := arg.
-					class := Smalltalk classNamed:className.
-					class isNil ifTrue:[
-					    StandAlone := true.
-					    self exitWithErrorMessage:'no such class: "', className, '".'
-					].
-					(class respondsTo:#main:) ifTrue:[
-					    class main:CommandLineArguments.
-					] ifFalse:[
-					    (class respondsTo:#main) ifTrue:[
-						class main.
-					    ] ifFalse:[
-						(class respondsTo:#start) ifTrue:[
-						    class start.
-						] ifFalse:[
-						    StandAlone := true.
-						    self exitWithErrorMessage:'class has no "main:", "main" or "start" method.'
-						].
-					    ].
-					].
-				    ].
-				].
-			    ].
-			].
-		    ].
-
-		    "/ after the script, if Screen has been opened and there are any open windows,
-		    "/ then do not exit
+                ] newProcess.
+                process priority:(Processor userSchedulingPriority).
+                process name:'main'.
+                process beGroupLeader.
+                process resume.
+
+                Processor dispatchLoop.
+                self exit
+            ].
+
+            "look for a '-f filename' or '--file filename' argument
+             if scripting, these are loaded before -P, -E or -R action.
+             if not scripting, this will force evaluation of filename instead of smalltalk.rc"
+            [
+                idxFileArg := CommandLineArguments indexOfAny:#('-f' '--file').
+                (idxFileArg ~~ 0)
+            ] whileTrue:[
+                commandFiles isNil ifTrue:[ commandFiles := OrderedCollection new ].
+                commandFiles add:(CommandLineArguments at:idxFileArg+1).
+                CommandLineArguments removeAtIndex:idxFileArg+1; removeAtIndex:idxFileArg.
+            ].
+
+            "/ look for a '-E expr' or '--eval expr' argument (-P or --print to print the result of evaluation)
+            "/ or -F/--filter or a '--repl' argument
+            "/ E, P and F this will force evaluation of expr only, no standard startup
+            "/ repl go into an interactive loop.
+            idx := CommandLineArguments indexOfAny:#('-E' '--eval').
+            (isEval := (idx ~~ 0)) ifFalse:[
+                idx := CommandLineArguments indexOfAny:#('-P' '--print').
+                (isPrint := (idx ~~ 0)) ifFalse:[
+                    idx := CommandLineArguments indexOfAny:#('-F' '--filter').
+                    (isFilter := (idx ~~ 0)) ifFalse:[
+                        idx := CommandLineArguments indexOfAny:#('-R' '--repl').
+                        (isRepl := (idx ~~ 0)) ifFalse:[
+                            idx := CommandLineArguments indexOfAny:#('--run').
+                            isRunMain := (idx ~~ 0)
+                        ].
+                    ].
+                ].
+            ].
+
+            (isEval | isPrint | isFilter | isRepl | isRunMain) ifTrue:[
+                |args|
+
+                VerboseStartup ifTrue:[
+                    ('Smalltalk [info]: eval/filter/print or repl') infoPrintCR.
+                ].
+                isRepl ifFalse:[
+                    CommandLineArguments size <= idx ifTrue:[
+                        StandAlone := true.
+                        self exitWithErrorMessage:'missing argument after -E/-P/-F/--run.'.
+                    ].
+                    isFilter ifTrue:[
+                        args := CommandLineArguments copyFrom:idx + 1.
+                        CommandLineArguments removeFromIndex:idx+1.
+                        VerboseStartup ifTrue:[
+                            ('Smalltalk [info]: filter expression(s): ') infoPrint.
+                            args infoPrintCR.
+                        ].
+                    ] ifFalse:[
+                        arg := CommandLineArguments at:idx + 1.
+                        CommandLineArguments removeAtIndex:idx+1.
+                        VerboseStartup ifTrue:[
+                            ('Smalltalk [info]: eval expression: ') infoPrint.
+                            arg infoPrintCR.
+                        ].
+                    ].
+                ].
+                CommandLineArguments removeAtIndex:idx.
+
+                self startSchedulerAndBackgroundCollector.
+
+                keepSplashWindow ifFalse:[ self hideSplashWindow ].
+                Initializing := false.
+
+                "/ set workspace variables
+                self defineCommandLineAsWorkspaceVariablesForScripts.
+
+                "/ all of the above allow for a -f file to be loaded before any other action
+                (commandFiles notEmptyOrNil) ifTrue:[
+                    commandFiles do:[:commandFile |
+                        (VerboseStartup | VerboseLoading) ifTrue:[
+                            ('Smalltalk [info]: reading command file from: "', commandFile, '".') infoPrintCR.
+                        ].
+                        Smalltalk silentlyLoadingDo:[
+                            (self secureFileIn:commandFile) ifFalse:[
+                                StandAlone := true.
+                                self exitWithErrorMessage:('"', commandFile, '" not found.').
+                            ]
+                        ]
+                    ]
+                ].
+
+                isRepl ifFalse:[
+                    Debugging == true ifFalse:[
+                        "/ remove the Debugger
+                        Debugger := nil.
+                    ].
+                ].
+
+                process := [
+                    self providingDisplayDo:[
+                        isRepl ifTrue:[
+                            Processor exitWhenNoMoreUserProcesses:false.
+                            Processor activeProcess name:'repl'.
+                            self readEvalPrintLoop.
+                            self exit.
+                        ].
+
+                        Processor exitWhenNoMoreUserProcesses:true.
+
+                        NoHandlerError handle:[:ex |
+                            Debugging == true ifTrue:[
+                                MiniDebugger enterException:ex.
+                            ] ifFalse:[
+                                Silent ifFalse:[
+                                    'Smalltalk [error]: ' _errorPrint. ex description _errorPrintCR.
+                                ].
+                                (VerboseStartup or:[ObjectMemory debugPrinting]) ifTrue:[
+                                    ex suspendedContext fullPrintAll.
+                                ].
+                                self exit:1.
+                            ].
+                            self exit:1.
+                            "/ ex reject.
+                        ] do:[
+                            UserInterrupt handle:[:ex |
+                                Debugging == true ifTrue:[
+                                    'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR.
+                                    "/ thisContext fullPrintAll.
+                                    MiniDebugger enterException:ex.
+                                    ex proceed.
+                                ].
+                                Silent ifFalse:[ 'user interrupt.' errorPrintCR ].
+                                self exit:128+(OperatingSystem sigINT).
+                            ] do:[
+                                |filterCode filterStart filterEnd|
+
+                                isFilter ifTrue:[
+                                    "/ --filter - apply code to each input line.
+                                    "/ compile code only once
+                                    (args size == 1) ifTrue:[
+                                        VerboseStartup ifTrue:[
+                                            'Smalltalk [info]: filter 1-arg' infoPrintCR.
+                                        ].
+                                        filterCode := args at:1.
+                                    ] ifFalse:[
+                                        (args size == 3) ifTrue:[
+                                            VerboseStartup ifTrue:[
+                                                'Smalltalk [info]: filter 3-arg' infoPrintCR.
+                                            ].
+                                            filterStart := args at:1.
+                                            filterCode := args at:2.
+                                            filterEnd := args at:3.
+                                        ] ifFalse:[
+                                            StandAlone := true.
+                                            self exitWithErrorMessage:'--filter must be followed by 1 or 3 expression arg(s)'
+                                        ].
+                                    ].
+                                    filterStart notEmptyOrNil ifTrue:[
+                                        VerboseStartup ifTrue:[
+                                            ('Smalltalk [info]: eval: "', filterStart, '"...') infoPrintCR.
+                                        ].
+                                        Compiler evaluate:filterStart notifying:(EvalScriptingErrorHandler new source:filterStart)
+                                    ].
+                                    VerboseStartup ifTrue:[
+                                        ('Smalltalk [info]: compile: "', filterCode, '"...') infoPrintCR.
+                                    ].
+                                    Compiler
+                                        compile:'doIt:line ',filterCode
+                                        forClass:String
+                                        notifying:(EvalScriptingErrorHandler new source:filterCode).
+
+                                    [Stdin atEnd] whileFalse:[
+                                        |line|
+
+                                        line := Stdin nextLine.
+                                        line doIt:line.
+                                    ].
+                                    filterEnd notEmptyOrNil ifTrue:[
+                                        VerboseStartup ifTrue:[
+                                            ('Smalltalk [info]: eval: "', filterEnd, '"...') infoPrintCR.
+                                        ].
+                                        Compiler evaluate:filterEnd notifying:(EvalScriptingErrorHandler new source:filterEnd)
+                                    ].
+                                ] ifFalse:[
+                                    (isPrint | isEval) ifTrue:[
+                                        "/ --print or --eval
+                                        |rslt|
+
+                                        rslt := Parser new
+                                                    evaluate:arg
+                                                    notifying:(EvalScriptingErrorHandler new source:arg)
+                                                    compile:true.
+                                        isPrint ifTrue:[
+                                            rslt printCR.
+                                        ].
+                                    ] ifFalse:[
+                                        "/ --run <className>
+                                        |className class|
+
+                                        className := arg.
+                                        class := Smalltalk classNamed:className.
+                                        class isNil ifTrue:[
+                                            StandAlone := true.
+                                            self exitWithErrorMessage:'no such class: "', className, '".'
+                                        ].
+                                        (class respondsTo:#main:) ifTrue:[
+                                            class main:CommandLineArguments.
+                                        ] ifFalse:[
+                                            (class respondsTo:#main) ifTrue:[
+                                                class main.
+                                            ] ifFalse:[
+                                                (class respondsTo:#start) ifTrue:[
+                                                    class start.
+                                                ] ifFalse:[
+                                                    StandAlone := true.
+                                                    self exitWithErrorMessage:'class has no "main:", "main" or "start" method.'
+                                                ].
+                                            ].
+                                        ].
+                                    ].
+                                ].
+                            ].
+                        ].
+                    ].
+
+                    "/ after the script, if Screen has been opened and there are any open windows,
+                    "/ then do not exit
 false ifTrue:[
-		    Display notNil ifTrue:[
-			Processor exitWhenNoMoreUserProcesses:true.
-			"/ Display exitOnLastClose:true.
-			"/ Display checkForEndOfDispatch.
-			VerboseStartup ifTrue:[
-			    ('Smalltalk [info]: display opened.') infoPrintCR.
-			].
-		    ] ifFalse:[
-			VerboseStartup ifTrue:[
-			    ('Smalltalk [info]: no display - exit after script.') infoPrintCR.
-			].
-			self exit.
-		    ].
+                    Display notNil ifTrue:[
+                        Processor exitWhenNoMoreUserProcesses:true.
+                        "/ Display exitOnLastClose:true.
+                        "/ Display checkForEndOfDispatch.
+                        VerboseStartup ifTrue:[
+                            ('Smalltalk [info]: display opened.') infoPrintCR.
+                        ].
+                    ] ifFalse:[
+                        VerboseStartup ifTrue:[
+                            ('Smalltalk [info]: no display - exit after script.') infoPrintCR.
+                        ].
+                        self exit.
+                    ].
 ].
-		    VerboseStartup ifTrue:[
-			('Smalltalk [info]: script/repl/eval finished.') infoPrintCR.
-		    ].
-
-		] newProcess.
-		process priority:(Processor userSchedulingPriority).
-		process name:'main'.
-		process beGroupLeader.
-		process resume.
-
-		Processor dispatchLoop.
-		VerboseStartup ifTrue:[
-		    ('Smalltalk [info]: exit normally.') infoPrintCR.
-		].
-		self exit
-	    ].
-	].
-
-	commandFiles notNil ifTrue:[
-	    SilentLoading := true.  "/ suppress the hello & copyright messages
-	    self addStartBlock:
-		[
-		    commandFiles do:[:commandFile |
-			(self secureFileIn:commandFile) ifFalse:[
-			    self exitWithErrorMessage:('startup file "', commandFile, '" not found.').
-			].
-		    ].
-		].
+                    VerboseStartup ifTrue:[
+                        ('Smalltalk [info]: script/repl/eval finished.') infoPrintCR.
+                    ].
+
+                ] newProcess.
+                process priority:(Processor userSchedulingPriority).
+                process name:'main'.
+                process beGroupLeader.
+                process resume.
+
+                Processor dispatchLoop.
+                VerboseStartup ifTrue:[
+                    ('Smalltalk [info]: exit normally.') infoPrintCR.
+                ].
+                self exit
+            ].
+        ].
+
+        commandFiles notNil ifTrue:[
+            SilentLoading := true.  "/ suppress the hello & copyright messages
+            self addStartBlock:
+                [
+                    commandFiles do:[:commandFile |
+                        VerboseStartup ifTrue:[('filing in %1' bindWith:commandFile) infoPrintCR].
+                        (self secureFileIn:commandFile) ifFalse:[
+                            self exitWithErrorMessage:('startup file "', commandFile, '" not found.').
+                        ].
+                    ].
+                ].
 
 "/            self startSchedulerAndBackgroundCollector.
 "/            keepSplashWindow ifFalse:[ self hideSplashWindow ].
@@ -4965,67 +4979,72 @@
 "/                ('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR.
 "/                OperatingSystem exit:1.
 "/            ].
-	] ifFalse:[
-	    "/ look for <command>.rc
-	    "/ if not found, read smalltalk.rc (or stxapp.rc for standAlone operation)
-
-	    rcFile := self commandName asFilename withSuffix:'rc'.
-	    (didReadRCFile := rcFile exists and:[self secureFileIn:rcFile]) ifFalse:[
-		StandAlone ifFalse:[
-		    defaultRC := 'smalltalk.rc' "/asFilename
-		] ifTrue:[
-		    defaultRC := 'stxapp.rc' "/asFilename
-		].
-		"JV@2011-11-01: DO NOT check defaultRC exist - this prevents smalltalk to
-		    to be started with different working directory than stx/projects/smalltalk !!!!!!"
-
-		"/didReadRCFile := defaultRC exists and:[self secureFileIn:defaultRC].
-		didReadRCFile := (self getSystemFileName:defaultRC) notNil
-				 and:[self secureFileIn:defaultRC].
-		didReadRCFile ifFalse:[
-		    StandAlone ifFalse:[
-			'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
-			graphicalMode := false.
-		    ]
-		]
-	    ].
-
-	    "/ ('StandAlone is %1' bindWith:StandAlone) printCR.
-	    "/ ('Headless is %1' bindWith:HeadlessOperation) printCR.
-	    "/ ('Display is %1' bindWith:Display) printCR.
-	    "/ ('Screen is %1' bindWith:Screen) printCR.
-
-	    keepSplashWindow ifFalse:[ self hideSplashWindow ].
-	    didReadRCFile ifFalse:[
-		'private.rc' asFilename exists ifTrue:[ self secureFileIn:'private.rc' ].
-
-		"/
-		"/ No RC file found;
-		"/ Setup more default stuff
-		"/
-		StandAlone ifFalse:[
-		    "/ its a smalltalk - proceed in interpreter.
-		    'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
-		    graphicalMode := false.
-		].
-
-		"/ setup more defaults...
+        ] ifFalse:[
+            "/ look for <command>.rc
+            "/ if not found, read smalltalk.rc (or stxapp.rc for standAlone operation)
+
+            rcFile := self commandName asFilename withSuffix:'rc'.
+            VerboseStartup ifTrue:[('filing in %1' bindWith:rcFile) infoPrintCR].
+            (didReadRCFile := rcFile exists and:[self secureFileIn:rcFile]) ifFalse:[
+                StandAlone ifFalse:[
+                    defaultRC := 'smalltalk.rc' "/asFilename
+                ] ifTrue:[
+                    defaultRC := 'stxapp.rc' "/asFilename
+                ].
+                "JV@2011-11-01: DO NOT check defaultRC exist - this prevents smalltalk to
+                    to be started with different working directory than stx/projects/smalltalk !!!!!!"
+
+                "/didReadRCFile := defaultRC exists and:[self secureFileIn:defaultRC].
+                VerboseStartup ifTrue:[('filing in %1' bindWith:defaultRC) infoPrintCR].
+                didReadRCFile := (self getSystemFileName:defaultRC) notNil
+                                 and:[self secureFileIn:defaultRC].
+                didReadRCFile ifFalse:[
+                    StandAlone ifFalse:[
+                        'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
+                        graphicalMode := false.
+                    ]
+                ]
+            ].
+
+            "/ ('StandAlone is %1' bindWith:StandAlone) printCR.
+            "/ ('Headless is %1' bindWith:HeadlessOperation) printCR.
+            "/ ('Display is %1' bindWith:Display) printCR.
+            "/ ('Screen is %1' bindWith:Screen) printCR.
+
+            keepSplashWindow ifFalse:[ self hideSplashWindow ].
+            didReadRCFile ifFalse:[
+                'private.rc' asFilename exists ifTrue:[ 
+                    VerboseStartup ifTrue:[('filing in private.rc') infoPrintCR].
+                    self secureFileIn:'private.rc' 
+                ].
+
+                "/
+                "/ No RC file found;
+                "/ Setup more default stuff
+                "/
+                StandAlone ifFalse:[
+                    "/ its a smalltalk - proceed in interpreter.
+                    'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR.
+                    graphicalMode := false.
+                ].
+
+                "/ setup more defaults...
 "/                ObjectMemory startBackgroundCollectorAt:5.
 "/                ObjectMemory startBackgroundFinalizationAt:5.
-		self addStartBlock:[
-		    self startSchedulerAndBackgroundCollector
-		].
-	    ].
-	].
-	(CommandLineArguments includes:'--scripting') ifTrue:[
-	    self addStartBlock:[
-		StandaloneStartup handleScriptingOptionsFromArguments:CommandLineArguments.
-	    ].
-	].
+                self addStartBlock:[
+                    self startSchedulerAndBackgroundCollector
+                ].
+            ].
+        ].
+        (CommandLineArguments includes:'--scripting') ifTrue:[
+            self addStartBlock:[
+                StandaloneStartup handleScriptingOptionsFromArguments:CommandLineArguments.
+            ].
+        ].
     ].
 
     HeadlessOperation ifTrue:[
-	graphicalMode := false.
+        graphicalMode := false.
     ].
 
     keepSplashWindow ifFalse:[ self hideSplashWindow ].
@@ -5033,6 +5052,7 @@
 
     "Modified: / 17-12-2013 / 16:44:40 / cg"
     "Modified: / 01-08-2017 / 11:08:47 / stefan"
+    "Modified: / 22-01-2019 / 14:01:44 / Claus Gittinger"
 !
 
 startSchedulerAndBackgroundCollector