1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 14:07:46 +00:00
I made minor corrections to upgrade to Rust nightly build.
This commit is contained in:
Joseph Crail 2015-04-30 17:06:38 -04:00
parent 4a6b7d33cb
commit 3465525d55

View file

@ -1,5 +1,5 @@
#![crate_name = "tty"] #![crate_name = "tty"]
#![feature(collections, core, old_io, rustc_private, std_misc)] #![feature(rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -12,14 +12,10 @@
* Synced with http://lingrok.org/xref/coreutils/src/tty.c * Synced with http://lingrok.org/xref/coreutils/src/tty.c
*/ */
#![allow(dead_code)]
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::CStr; use std::ffi::CStr;
use std::old_io::println;
use std::old_io::stdio::stderr;
use getopts::{optflag,getopts}; use getopts::{optflag,getopts};
#[path = "../common/util.rs"] #[path = "../common/util.rs"]
@ -38,7 +34,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
optflag("s", "silent", "print nothing, only return an exit status") optflag("s", "silent", "print nothing, only return an exit status")
]; ];
let silent = match getopts(args.tail(), &options) { let silent = match getopts(&args[1..], &options) {
Ok(m) => { Ok(m) => {
m.opt_present("s") m.opt_present("s")
}, },
@ -59,8 +55,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
}; };
if !silent { if !silent {
if !tty.as_slice().chars().all(|c| c.is_whitespace()) { if !tty.chars().all(|c| c.is_whitespace()) {
println(tty.as_slice()); println!("{}", tty);
} else { } else {
println!("not a tty"); println!("not a tty");
} }
@ -77,6 +73,6 @@ pub fn uumain(args: Vec<String>) -> i32 {
exit_code exit_code
} }
fn usage () { fn usage() {
safe_writeln!(&mut stderr(), "usage: tty [-s]"); println!("usage: {} [-s]", NAME);
} }