yac
/
coreutils
Archived
2
0
Fork 0

cat(1): statically linked sysexits

This commit is contained in:
Emma Tebibyte 2022-12-09 23:06:22 -05:00
parent 346702d58e
commit bf6d149e07
6 changed files with 8 additions and 41 deletions

9
Cargo.lock generated
View File

@ -6,14 +6,7 @@ version = 3
name = "coreutils"
version = "0.0.1"
dependencies = [
"sysexits 0.1.0",
]
[[package]]
name = "sysexits"
version = "0.1.0"
dependencies = [
"sysexits 0.3.4",
"sysexits",
]
[[package]]

View File

@ -9,7 +9,7 @@ authors = [
]
[dependencies]
sysexits = { version = "0.1.0", path = "sysexits", package = "sysexits" }
sysexits = "0.3.4"
[[bin]]
name = "cat"

View File

@ -5,9 +5,9 @@ use std::fs::read_to_string;
use std::io;
use std::io::Write;
use std::env;
use std::process;
use sysexits::ExitCode;
fn main() {
fn main() -> ExitCode {
let mut args: Vec<String> = env::args().collect();
let argv0 = args.remove(0);
let mut opts = Vec::new();
@ -29,7 +29,7 @@ fn main() {
_ => {
println!("Usage: {} [options...] [files...]", argv0);
process::exit(64); // sysexits(3) EX_USAGE
return ExitCode::Usage;
},
};
}
@ -44,7 +44,7 @@ fn main() {
Ok(_) => { val.push_str(&content); },
Err(_) => {
println!("Usage: {} [options...] [files...]", argv0);
process::exit(64); // sysexits(3) EX_USAGE
return ExitCode::Usage;
},
};
},
@ -54,7 +54,7 @@ fn main() {
Ok(output) => { val.push_str(&output); },
Err(_) => {
println!("{}: {}: No such file or directory.", argv0, path);
process::exit(66); // sysexits(3) EX_NOINPUT
return ExitCode::NoInput;
},
};
},
@ -63,4 +63,5 @@ fn main() {
}
io::stdout().flush().unwrap();
ExitCode::Ok
}

16
sysexits/Cargo.lock generated
View File

@ -1,16 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "sysexits"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "913b6c9c3fdc55ec78e76e281706cecfe0cfb4ba07545cbce8342ed943dcfa72"
[[package]]
name = "sysexits-dynamic"
version = "0.1.0"
dependencies = [
"sysexits",
]

View File

@ -1,10 +0,0 @@
[package]
name = "sysexits"
version = "0.1.0"
edition = "2021"
[dependencies]
sysexits = "0.3.4"
[lib]
crate-type = ["dylib"]

View File

@ -1 +0,0 @@
pub use sysexits::*;