bugGNU Octave - Bugs: bug #48541, kbhit returns...

 
 

bug #48541: kbhit returns "undefined" when starting script from terminal

Submitter:  None
Submitted:  Sun 17 Jul 2016 11:34:24 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Marc Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 08 Apr 2018 10:46:00 PM UTC, comment #7: 

Francisco - I suggest you bring this up in a new bug report, or look at bug #53412.

Mike Miller <mtmiller>
Group Member
Sun 08 Apr 2018 09:42:10 PM UTC, comment #6: 

While it makes sense to assume that scripts are for batch processing, GNU/Octave is a powerful dynamic language, with which you can implement interactive applications. For example, for games, where keyboard-mediated interaction is essential, 'kbhit()' is a must. (We're actually running a major project on that, and that's the reason we ended up here.)

Are there plans to fix this in the future?

Francisco Vico <nightcod3r>
Mon 18 Jul 2016 06:44:55 PM UTC, comment #5: 

Alright, sounds good to me, pushed this fix on default,

http://hg.savannah.gnu.org/hgweb/octave/rev/ed6104a78ebf

Mike Miller <mtmiller>
Group Member
Mon 18 Jul 2016 06:32:59 PM UTC, comment #4: 

If it is never meant to be used in batch mode, maybe kbhit should just return immediately with an empty value?  At least that would be a sensible position, even if people don't particularly like it.

Rik <rik5>
Group administrator
Mon 18 Jul 2016 06:17:21 PM UTC, comment #3: 

Oh, now I see that the kbhit function is simply looking at Octave's "interactive" flag.

That flag is set to false when running batch commands. So what should kbhit return when run in a batch context? Should kbhit behave differently when piping input to Octave via stdin versus using --eval?

Mike Miller <mtmiller>
Group Member
Mon 18 Jul 2016 05:45:19 PM UTC, comment #2: 

I see this behavior even when run as


octave-cli --interactive --line-editing --persist --eval 'x = kbhit ()'


This would normally work around any problems of setting up Octave without readline or without terminal initialization. It looks like it might be something that hasn't been set up yet at the point when the --eval strings are processed.

Mike Miller <mtmiller>
Group Member
Mon 18 Jul 2016 02:24:20 PM UTC, comment #1: 

Confirmed.  This is probably because scripts run on the command line are usually intended to do batch processing and so no connection is made to an input console.  This affects the current development branch as well.

Rik <rik5>
Group administrator
Sun 17 Jul 2016 11:34:24 AM UTC, original submission:  

I use kbhit for user interaction.

For example (cf. attached showcase.m):

a = kbhit()


When I run the script from within octave everything is fine.
But when I run the same script from the terminal by issuing

octave-cli showcase.m

I get the following error: "error: value on right hand side of assignment is undefined"








Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37920:  showcase.m added by None (13B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nightcod3r (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-18 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-07-18 rik5 Item GroupSegfault, Bus Error, etc. Incorrect Result
        StatusNone Confirmed
        Release4.0.0 dev
    2016-07-17 None Attached File- Added showcase.m, #37920

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code