This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Different behavior for -s argument in Kawa 2.0?
- From: Per Bothner <per at bothner dot com>
- To: kawa at sourceware dot org, Jeff Gonis <jeff dot gonis at gmail dot com>
- Date: Fri, 09 Jan 2015 15:39:27 -0800
- Subject: Re: Different behavior for -s argument in Kawa 2.0?
- Authentication-results: sourceware.org; auth=none
- References: <CAFVyn8RdRnhc9DGpzT=oA6sQ0oWcbRM71hYvVUROV+7grKkTMQ at mail dot gmail dot com> <CAFVyn8SzaE6Og3UT9+CXQJoPLRBZ7BD6pRSRznUcrxpZVXEC8w at mail dot gmail dot com> <54B03F22 dot 7050801 at bothner dot com> <CAFVyn8S9Tdzdwmczg883U2yXmZUmRMxArtf2sXBKA2HhjXTCNA at mail dot gmail dot com> <687DFB7D-EADA-43CC-9242-B1A0C9C8B7A2 at theptrgroup dot com> <54B05E87 dot 1050101 at bothner dot com>
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;