sbcl wrong behavior in Windows terminal

Bug #1660906 reported by Jinsong Zhao on 2017-02-01
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

Hi there,

I *think* sbcl does not properly deal with the new-line or line-endings character. In windows terminal, I mean ``cmd'' on Windows platform, You can reproduce the issue with the following code:
```
* (defun a) ;with a return

debugger invoked on a SB-KERNEL::ARG-COUNT-ERROR in thread
#<THREAD "main thread" RUNNING {1002954623}>:
  error while parsing arguments to DEFMACRO DEFUN:
    too few elements in
      (A)
    to satisfy lambda list
      (SB-IMPL::NAME SB-IMPL::LAMBDA-LIST &BODY SB-IMPL::BODY):
    at least 2 expected, but got 1

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

```
there is still another line not be printed, at this point, press the return, the line will appear:
```

(SB-C::CHECK-DS-LIST/&REST #<unavailable argument> #<unavailable argument> #<unavailable argument> #<unavailable argument>)
0]
```

There is another case I *think* that it may related to the same thing. Below is the lisp code:
```
(defun read-with-default (prompt default)
  (format t "~a [~a]: " prompt default)
  (terpri)
  (let ((response (read-line)))
    (if (string= response "") default response)))

(let ((a)
      (b))
  (setf a (read-with-default "a > " "a"))
  (setf b (read-with-default "b > " "b")))
```
In Windows ``cmd'', the output is like:
```
* (defun read-with-default (prompt default)
  (format t "~a [~a]: " prompt default)
  (terpri)
  (let ((response (read-line)))
    (if (string= response "") default response)))

READ-WITH-DEFAULT
* (let ((a)
      (b))
  (setf a (read-with-default "a > " "a"))
  (setf b (read-with-default "b > " "b")))
a > [a]:
b > [b]:
"b"
"\"b\"
*
```
You may notice that the (setf a (read-with-default "a > " "a")) dose not give chance to user to input anything. and the (setf a (read-with-default "a > " "a")) response to user, but does not give correct echo, it should be "\"b\""

The sbcl works well on MYSY2 terminal. Thus, it may be a Windows terminal specific issue.

The version of sbcl I used.
C:\Users\LENOVO>sbcl --version
SBCL 1.3.12

The system I used is:
Microsoft Windows 10 Professional, ver. 10.0.14393

Best regards,
Jinsong

Stas Boukarev (stassats) wrote :

This is because clear-input tries to read from the stream.
This is because listen returns t.
This is because it claims to do something special with console handles and claims that the first two bits of console handles #b11, which is untrue.
This is because the whole OS layer is a a mess.

Changed in sbcl:
status: New → Triaged
importance: Undecided → Medium
tags: added: os-windows
Stas Boukarev (stassats) wrote :

In 43d8ec05f7591470c6fac3c2e19aac1e4c72caeb.

Changed in sbcl:
status: Triaged → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers