1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

moved more to unix utils, minor review updates

This commit is contained in:
Martin Kysel 2016-08-23 11:40:09 +01:00
parent a90aec3f1b
commit 23bab3df69
2 changed files with 5 additions and 7 deletions

View file

@ -21,6 +21,7 @@ unix = [
"logname", "logname",
"mkfifo", "mkfifo",
"mknod", "mknod",
"more",
"mv", "mv",
"nice", "nice",
"nohup", "nohup",
@ -63,7 +64,6 @@ generic = [
"ls", "ls",
"mkdir", "mkdir",
"mktemp", "mktemp",
"more",
"nl", "nl",
"nproc", "nproc",
"od", "od",

View file

@ -15,7 +15,7 @@ extern crate getopts;
extern crate uucore; extern crate uucore;
use getopts::Options; use getopts::Options;
use std::io::{stdout, stdin, stderr, Write, Read, Result}; use std::io::{stdout, Write, Read};
use std::fs::File; use std::fs::File;
extern crate nix; extern crate nix;
@ -75,12 +75,11 @@ fn help(usage: &str) {
} }
fn more(matches: getopts::Matches) { fn more(matches: getopts::Matches) {
let mut files = matches.free; let files = matches.free;
let mut f = File::open(files.first().unwrap()).unwrap(); let mut f = File::open(files.first().unwrap()).unwrap();
let mut buffer = [0; 1024]; let mut buffer = [0; 1024];
let saved_term = termios::tcgetattr(0).unwrap(); let mut term = termios::tcgetattr(0).unwrap();
let mut term = saved_term;
// Unset canonical mode, so we get characters immediately // Unset canonical mode, so we get characters immediately
term.c_lflag.remove(termios::ICANON); term.c_lflag.remove(termios::ICANON);
// Disable local echo // Disable local echo
@ -92,8 +91,7 @@ fn more(matches: getopts::Matches) {
if sz == 0 { break; } if sz == 0 { break; }
stdout().write(&buffer[0..sz]).unwrap(); stdout().write(&buffer[0..sz]).unwrap();
for byte in std::io::stdin().bytes() { for byte in std::io::stdin().bytes() {
let byte = byte.unwrap(); match byte.unwrap() {
match byte {
b' ' => break, b' ' => break,
b'q' | 27 => { b'q' | 27 => {
end = true; end = true;