This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Different behavior for -s argument in Kawa 2.0?




On 01/09/2015 03:04 PM, Per Bothner wrote:
A possible solution is to add a --console flag (similar to
sh's -i flag), which would be the inverse of the --no-console flag,
in that it would force haveConsole to return true.

Please try the attached patch.  You will need to specify --console.
You shouldn't don't need to specify -s.

(BTW one reason this got changed in 2.0 was to support binary input files.
I.e. you can now write a Kawa program that reads a binary file from the standard input port
- but only if InPort.haveConsole() returns false.)
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Index: gnu/kawa/io/InPort.java
===================================================================
--- gnu/kawa/io/InPort.java	(revision 8255)
+++ gnu/kawa/io/InPort.java	(working copy)
@@ -31,11 +31,17 @@
 
 public class InPort extends Reader implements Printable
 {
-    public static boolean noConsole;
+    private static int haveConsole;
 
+    public static void setHaveConsole(boolean value) {
+        haveConsole = value ? 1 : -1;
+    }
+
     public static boolean haveConsole() {
-        if (noConsole)
+        if (haveConsole < 0)
             return false;
+        if (haveConsole > 0)
+            return true;
         /* #ifdef JAVA6 */
         return System.console() != null;
         /* #else */
Index: kawa/GuiConsole.java
===================================================================
--- kawa/GuiConsole.java	(revision 8255)
+++ kawa/GuiConsole.java	(working copy)
@@ -27,7 +27,7 @@
   ReplDocument document;
 
   public static void main(String[] args) {
-    InPort.noConsole = false;
+    InPort.setHaveConsole(true);
     int iArg = repl.processArgs(args, 0, args.length);
     repl.getLanguage();
     repl.setArgs(args, iArg);
Index: kawa/repl.java
===================================================================
--- kawa/repl.java	(revision 8257)
+++ kawa/repl.java	(working copy)
@@ -651,7 +651,9 @@
 	    Compilation.inlineOk = false;
 	  }
         else if (arg.equals("--no-console"))
-          InPort.noConsole = true;
+            InPort.setHaveConsole(false);
+	else if (arg.equals("--console"))
+            InPort.setHaveConsole(true);
 	else if (arg.equals("--inline"))
 	  {
 	    Compilation.inlineOk = true;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]