mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +00:00
Fix tty.
I made minor corrections to upgrade to Rust nightly build.
This commit is contained in:
parent
4a6b7d33cb
commit
3465525d55
1 changed files with 6 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
#![crate_name = "tty"]
|
||||
#![feature(collections, core, old_io, rustc_private, std_misc)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
/*
|
||||
* This file is part of the uutils coreutils package.
|
||||
|
@ -12,14 +12,10 @@
|
|||
* Synced with http://lingrok.org/xref/coreutils/src/tty.c
|
||||
*/
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::old_io::println;
|
||||
use std::old_io::stdio::stderr;
|
||||
use getopts::{optflag,getopts};
|
||||
|
||||
#[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")
|
||||
];
|
||||
|
||||
let silent = match getopts(args.tail(), &options) {
|
||||
let silent = match getopts(&args[1..], &options) {
|
||||
Ok(m) => {
|
||||
m.opt_present("s")
|
||||
},
|
||||
|
@ -59,8 +55,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
};
|
||||
|
||||
if !silent {
|
||||
if !tty.as_slice().chars().all(|c| c.is_whitespace()) {
|
||||
println(tty.as_slice());
|
||||
if !tty.chars().all(|c| c.is_whitespace()) {
|
||||
println!("{}", tty);
|
||||
} else {
|
||||
println!("not a tty");
|
||||
}
|
||||
|
@ -78,5 +74,5 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
}
|
||||
|
||||
fn usage() {
|
||||
safe_writeln!(&mut stderr(), "usage: tty [-s]");
|
||||
println!("usage: {} [-s]", NAME);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue