Smalltalk.st
changeset 19510 80255da5931a
parent 19492 8422ce672a77
child 19511 96c72a572feb
--- a/Smalltalk.st	Thu Mar 31 14:28:41 2016 +0200
+++ b/Smalltalk.st	Thu Mar 31 15:14:48 2016 +0200
@@ -617,7 +617,7 @@
         this is NOT called when an image is restarted;
         in this case the show starts in Smalltalk>>restart."
 
-    |idx|
+    |idx shellArgs|
 
     NumberOfClassesHint := 10000.
 
@@ -638,6 +638,33 @@
     self initializeVerboseFlags.    
 
     DebuggingStandAlone := Debugging := false.
+
+    "/ if no argument was given, look for an environment variable named
+    "/ STX_DEFAULT_ARGS. If set, take that.
+    "/ if any argument was given, unless a --noShellArgs argument is given,
+    "/ slice in the value from "STX_MORE_ARGS" at the beginning.
+    "/
+    "/ These allow for args like "--quick --infoPrint" to be automatically prepended
+    idx := CommandLineArguments indexOf:'--noShellArgs'.
+    (idx ~~ 0) ifTrue:[
+        CommandLineArguments removeIndex:idx.
+    ] ifFalse:[   
+        CommandLineArguments isEmpty ifTrue:[
+            shellArgs := OperatingSystem getEnvironment:'STX_DEFAULT_ARGS'.
+            shellArgs notEmptyOrNil ifTrue:[
+                shellArgs := shellArgs asCollectionOfWords.
+                CommandLineArguments addAll:shellArgs.
+            ].
+        ] ifFalse:[
+            "/ prepend shell environment args from "STX_ARGS"
+            shellArgs := OperatingSystem getEnvironment:'STX_MORE_ARGS'.
+            shellArgs notEmptyOrNil ifTrue:[
+                shellArgs := shellArgs asCollectionOfWords.
+                CommandLineArguments addAllFirst:shellArgs.
+            ].
+        ].
+    ].
+
     idx := CommandLineArguments indexOf:'--debug'.
     Debugging := (idx ~~ 0).