[MacRuby] #1255: HighLine Gem - stty: stdin isn't a terminal
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Consider the following code. {{{ require 'rubygems' require 'highline' h = HighLine.new h.ask("Password: ") {|x| x.echo = "*"} }}} The last line is supposed to let you type in masked characters (masked with *), but instead this is what MacRuby nightly (05/03) produces. {{{ Password: stty: stdin isn't a terminal speed 9600 baud; lflags: -icanon -iexten -echo echoke echoctl iflags: -icrnl -ixon -imaxbel iutf8 ignbrk -brkint oflags: -opost -oxtabs cflags: cs8 -parenb => "" }}} The weird indentation is neither mine nor Trac's. I'm pasting direct from the console. -- Ticket URL: <http://www.macruby.org/trac/ticket/1255> MacRuby <http://macruby.org/>
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by lastobelus@…): A workaround until this gets fixed is to do this: {{{ class HighLine def raw_no_echo_mode system "stty raw -echo" end def restore_mode system "stty -raw echo" end end }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1255#comment:1> MacRuby <http://macruby.org/>
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by lastobelus@…): it seems like system creates a subshell in a different way than backticks or popen or popen3 do. I wasn't able to find any way to run stty and capture its output, but running it with system doesn't cause the problem. -- Ticket URL: <http://www.macruby.org/trac/ticket/1255#comment:2> MacRuby <http://macruby.org/>
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by lastobelus@…): This is probably a better patch: {{{ class HighLine def raw_no_echo_mode @state = `stty -g < /dev/tty` system "stty raw -echo -icanon isig" end end }}} Unfortunately however, another bug remains with macruby / highline, which is when NOT using character mode (or turning off echo, which uses character mode behind the scenes) Highline#ask and Highline#choose are losing the first character of input. I haven't figured out what exactly is happening there; the relevant highline code is a little convoluted and I haven't needed to fix it yet. -- Ticket URL: <http://www.macruby.org/trac/ticket/1255#comment:3> MacRuby <http://macruby.org/>
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by lastobelus@…): macirb session illustrating the second bug: {{{ lasto:~$ macirb irb(main):001:0> require 'highline' => true irb(main):002:0> h = HighLine.new => #<HighLine:0x2002d1c20 @input=#<IO:<STDIN>> @output=#<IO:<STDOUT>> @wrap_at=nil @page_at=nil @question=nil @answer=nil @menu=nil @header=nil @prompt=nil @gather=nil @answers=nil @key=nil> irb(main):003:0> p = h.ask("type 'bob': ") type 'bob': bob => "ob" irb(main):004:0> }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1255#comment:4> MacRuby <http://macruby.org/>
#1255: HighLine Gem - stty: stdin isn't a terminal -------------------------------------+-------------------------------------- Reporter: umairsiddique@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by lastobelus@…): I isolated the problem with HighLine#ask to a macruby bug in STDIN: http://www.macruby.org/trac/ticket/1429 -- Ticket URL: <http://www.macruby.org/trac/ticket/1255#comment:5> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby