bugGNU Octave - Bugs: bug #64908, Cut/paste "pause" into...


bug #64908: Cut/paste "pause" into command window may cause unexpected results

Submitter:  Liang Tang <lt1234>
Submitted:  Sun 19 Nov 2023 08:24:24 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  lt1234 Open/Closed:  * Open
Release:  * 8.2.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Wed 22 Nov 2023 02:29:12 AM UTC, comment #11: 

Arun, I am a holdout. Win10.

Liang Tang <lt1234>
Wed 22 Nov 2023 02:23:25 AM UTC, comment #10: 

Is it correct that this incompatibility affects only Windows and not Unix-like platforms? I'm marking it as such.

Reading https://github.com/microsoft/terminal/issues/395 it looks like Windows 11 does have bracketed paste. I couldn't find any info on older Windows versions.

@Liang, are you on Windows 11?

Arun Giridhar <arungiridhar>
Group Member
Mon 20 Nov 2023 10:03:58 PM UTC, comment #9: 

I looked in my .inputrc file and there was just one line explicitly disabling bracketed paste with no comment explaining why. I must have done that years ago to work around something else.

Enabling that option in .inputrc makes OP's code behave properly for me, and similar to how Matlab's behavior was described.

So, the behavior works for me now in a Matlab-compatible way.

Arun Giridhar <arungiridhar>
Group Member
Mon 20 Nov 2023 09:43:15 PM UTC, comment #8: 

ok, that seems correct then.  i just tried the experimental terminal widget on 8.4.0 and paste behavior there behaves in the 'bracketed' sense.

Nicholas Jankowski <nrjank>
Group Member
Mon 20 Nov 2023 07:31:12 PM UTC, comment #7: 

That is also the behavior of both the Octave GUI and CLI terminal application interface on Unixy systems.  That's the "bracketed paste mode" that I was referring to.  I guess the GUI terminal widget on Windows does not implement that feature?

John W. Eaton <jwe>
Group administrator
Mon 20 Nov 2023 07:13:14 PM UTC, comment #6: 

note that matlab does seem to separate keyboard and paste events.  when you paste in a multiline block in Octave, each line is interpreted and processed one at a time.  when you do the same in matlab, the entire block is pasted in, and none is executed until you hit enter, then it processes the block (i assume as if it were a script file)

Nicholas Jankowski <nrjank>
Group Member
Mon 20 Nov 2023 06:37:35 PM UTC, comment #5: 

I assume we are looking at what happens with the Matlab GUI?

For the GUI, we might be able to distinguish between input that comes in through a paste event and actual keyboard events.

For the command-line terminal mode application, maybe something similar could be done with the way we process pasted input, but probably only when "bracketed paste mode" is enabled for readline.

John W. Eaton <jwe>
Group administrator
Mon 20 Nov 2023 03:08:45 PM UTC, comment #4: 

It seems that Matlab's pause() implements two different input streams instead of drawing the key press character from the standard input stream where the pasted characters are being read? Not sure how to implement that. Does getchar() know the difference between an input stream and a keyboard? Pretty sure getch() is not portable.

It seems that the C++ standard abstracts it to streams and there's no specific way to define a keyboard, hence no portable way to wait for a key press. Guessing Matlab does this with system("PAUSE") or equivalent?

Arun Giridhar <arungiridhar>
Group Member
Mon 20 Nov 2023 02:50:42 PM UTC, comment #3: 

matlab 2023b waits for a keystroke in all examples of 'pause()' with no delay specified no matter what combination of copy/paste i attempt

Nicholas Jankowski <nrjank>
Group Member
Sun 19 Nov 2023 08:59:45 PM UTC, comment #2: 

Oh, wait, now I see what's happening when pasting it.

When you type pause without arguments, it waits for a keystroke from the user before proceeding. Since the buffer already has more characters after the pause being pasted, the pause command immediately gives back control to what follows it.

Try pause (1) or some time delay and it will work.

It doesn't seem like a bug to me. Just to be complete, what does Matlab do? Does it wait for any keystroke or specifically the enter key?

Arun Giridhar <arungiridhar>
Group Member
Sun 19 Nov 2023 08:55:08 PM UTC, comment #1: 

It works as intended on Linux. The variants I tried in addition to yours were:

a = 0, b = 1

a = 0, pause, b = 1

a = 0, pause (1), b = 1

All three work as intended for me.

Not sure if this is a Windows-only bug? Could someone check pls?

What does Matlab do?

Arun Giridhar <arungiridhar>
Group Member
Sun 19 Nov 2023 08:24:24 PM UTC, original submission:  

I ran into an issue for a use case of pause in the command window.  pause were entered through text cut/paste, not keyboard.   Text editor I have is notepad++.

Please cut/paste these below into command window.  These two groups are the same except, for the latter, a carriage return is entered right after the pause.

When I pasted the lines, the first pause does not work at all. 0 and 1 were displayed automatically without any feedback from me. After all done, I then used arrow up key back to the first line, pause works under this condition.

For the 2nd pause, at the end of the line, below, the first character of the line is always ignored/missing.

display(0); pause, display(1)
display(0); pause,

>> display(0); pause, display(1)


>> isplay(0); pause,

error: 'isplay' undefined near line 1, column 1

>> display(1)

Liang Tang <lt1234>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by lt1234 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-11-22 arungiridhar Operating SystemAny Microsoft Windows
    2023-11-20 arungiridhar Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code