Stebalien / term

A Rust library for terminfo parsing and terminal colors.
https://stebalien.github.io/doc/term/term/
Apache License 2.0
178 stars 49 forks source link

Term crashes on FreeBSD #75

Closed Licenser closed 7 years ago

Licenser commented 7 years ago

Running the example program:

extern crate term;
use std::io::prelude::*;

fn main() {
    let mut t = term::stdout().unwrap();

    t.fg(term::color::GREEN).unwrap();
    write!(t, "hello, ").unwrap();

    t.fg(term::color::RED).unwrap();
    writeln!(t, "world!").unwrap();

    t.reset().unwrap();
}

on freebsd ends with the following error:

[root@fifo-bsd ~/term-test]# RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/term-test`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /buildslave/rust-buildbot/slave/stable-dist-rustc-cross-host-linux/build/src/libcore/option.rs:323

this happens in the line (Deducted by 'cleverly ' sprinkeling the example with println!)

let mut t = term::stdout().unwrap();
Stebalien commented 7 years ago

That should have been followed by a backtrace... From what I can tell, term isn't crashing, it's just returning None.

What version are you using? What's your $TERM set to? Unfortunately, we don't have real FreeBSD support because most BSDs use different terminfo database format. Instead, we whitelist a set of terminals known to be ANSI compatible (and use a built-in ANSI terminfo database).

Licenser commented 7 years ago

Hi sorry, about that, I'm quite new to the rust world and don't know really how to best report a bug :)

the backtrace looks rather odd:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /buildslave/rust-buildbot/slave/stable-dist-rustc-cross-host-linux/build/src/libcore/option.rs:323
stack backtrace:
   1:          0x107ddfc - <unknown>
   2:          0x108007e - <unknown>
   3:          0x107fd41 - <unknown>
   4:          0x1080465 - <unknown>
   5:          0x10802a4 - <unknown>
   6:          0x1080219 - <unknown>
   7:          0x10801a7 - <unknown>
   8:          0x10ac7fd - <unknown>
   9:          0x10ac734 - <unknown>
  10:          0x103171e - <unknown>
  11:          0x10324bc - <unknown>
  12:          0x108809a - <unknown>
  13:          0x108091a - <unknown>
  14:          0x10326d2 - <unknown>
  15:          0x10315b0 - <unknown>
  16:        0x8012f8fff - <unknown>

TERM is set to xterm-256color.

What surprised me is that getting the stdout seem to have failed instead of it just showing no colours.

Stebalien commented 7 years ago

How did you run that? With debugging symbols, you should get an actual backtrace. Did you run RUST_BACKTRACE=1 cargo run?

What surprised me is that getting the stdout seem to have failed instead of it just showing no colours.

Eventually, I'd like to write a "smart" terminal that just does what you want. However, that's not what this terminal does (blindly unwrapping will lead to surprises like this).

TERM is set to xterm-256color.

/headdesk. I didn't actually cut a release for the version with fallback support. Try 0.4.6.

Licenser commented 7 years ago

Heya 0.4.6 works like a charm :D thank you!!!!!! Going to close this since it seems that was really the only problem ^.^

Stebalien commented 7 years ago

I take it it worked?

Licenser commented 7 years ago

Absolutely, sorry I wasn't clear enough :)

Stebalien commented 7 years ago

No problem. I just don't have a FreeBSD box to test on so I look for confirmation that it's working every chance I get.