#357 Bug: ctrl-d in fansh bombs

f00biebletch Thu 4 Sep 2008

hit ctrl-d (traditional shell quit/logout) at any time gives the following on mac osx:

snark:~ kevin$ fansh
Fan Shell v1.0.31 ('?' for help)
fansh> sys::NullErr: java.lang.NullPointerException
fansh::Shell.run (Shell.fan:32)
fansh::Main.main (Shell.fan:162)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke  (DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke (Method.java:585)
fan.sys.Method.invoke (Method.java:515)
fan.sys.Method$MethodFunc.call (Method.java:216)
fan.sys.Method.call (Method.java:178)
fanx.tools.Fan.callMain (Fan.java:132)
fanx.tools.Fan.executeType (Fan.java:99)
fanx.tools.Fan.execute (Fan.java:40)
fanx.tools.Fan.run (Fan.java:225)
fanx.tools.Fan$1.run (Fan.java:267)
fan.sys.Thread$Val.run (Thread.java:453)

cgrinds Thu 4 Sep 2008

Hello f00biebletch,

This should fix the bug.

=== modified file 'fan/Shell.fan'
--- fan/Shell.fan       2008-09-04 03:55:44 +0000
+++ fan/Shell.fan       2008-09-04 03:57:02 +0000
@@ -29,7 +29,13 @@
     {
       // input next line
       out.print("fansh> ").flush
-      line := in.readLine.trim
+      line := in.readLine
+      if(line == null)
+      {
+        isAlive = false
+        continue
+      }
+      line = line.trim
       if (line.size == 0) continue

       // check if line maps to predefined command

f00biebletch Thu 4 Sep 2008

Thanks, I had patched it with

line := in.readLine?.trim

which felt kinda groovy, although ruby > groovy anyday!

brian Thu 4 Sep 2008

this fix is checked in for next build

Login or Signup to reply.