From b65d0617bca7bf85970854c728c37d935421ea14 Mon Sep 17 00:00:00 2001 From: Ren Kararou Date: Fri, 26 May 2023 17:25:38 -0400 Subject: rename files for clarity --- usr/src/mei/echo/Cargo.toml | 2 +- usr/src/mei/echo/src/echo.rs | 90 ++++++++++++++++++++++++++++++++++++++++ usr/src/mei/echo/src/main.rs | 90 ---------------------------------------- usr/src/mei/printf/Cargo.toml | 2 +- usr/src/mei/printf/src/main.rs | 3 -- usr/src/mei/printf/src/printf.rs | 3 ++ usr/src/mei/pwd/Cargo.toml | 2 +- usr/src/mei/pwd/src/main.rs | 42 ------------------- usr/src/mei/pwd/src/pwd.rs | 42 +++++++++++++++++++ usr/src/mei/true/Cargo.toml | 2 +- usr/src/mei/true/src/main.rs | 31 -------------- usr/src/mei/true/src/true.rs | 31 ++++++++++++++ usr/src/mei/yes/Cargo.toml | 2 +- usr/src/mei/yes/src/main.rs | 41 ------------------ usr/src/mei/yes/src/yes.rs | 41 ++++++++++++++++++ 15 files changed, 212 insertions(+), 212 deletions(-) create mode 100644 usr/src/mei/echo/src/echo.rs delete mode 100644 usr/src/mei/echo/src/main.rs delete mode 100644 usr/src/mei/printf/src/main.rs create mode 100644 usr/src/mei/printf/src/printf.rs delete mode 100644 usr/src/mei/pwd/src/main.rs create mode 100644 usr/src/mei/pwd/src/pwd.rs delete mode 100644 usr/src/mei/true/src/main.rs create mode 100644 usr/src/mei/true/src/true.rs delete mode 100644 usr/src/mei/yes/src/main.rs create mode 100644 usr/src/mei/yes/src/yes.rs (limited to 'usr') diff --git a/usr/src/mei/echo/Cargo.toml b/usr/src/mei/echo/Cargo.toml index 0b34ec5..8ec00ee 100644 --- a/usr/src/mei/echo/Cargo.toml +++ b/usr/src/mei/echo/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [[bin]] name = "echo" -path = "src/main.rs" +path = "src/echo.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/usr/src/mei/echo/src/echo.rs b/usr/src/mei/echo/src/echo.rs new file mode 100644 index 0000000..ad5eee9 --- /dev/null +++ b/usr/src/mei/echo/src/echo.rs @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2023 Ren Kararou All rights reserved. + * Use is subject to license terms. + */ + +use std::env; + +fn main() { + let print: String = env::args().skip(1).collect::>().join(" "); + // This does not currently mimic functionality of illumos echo + if print.is_empty() { + println!(""); + } else { + println!("{print}"); + } + + // This mimics illumos echo functionality, or it should + /* + let mut esc: bool = false; + let mut is_num: bool = false; + let mut oct: String = "".to_string(); + let mut oc: u8 = 0; + + for c in print.chars() { + if !esc { + if c == '\\' { + esc = true; + } else { + print!("{c}"); + } + } else { + match c { + // "unknown character escape" wtf rust these are valid. + //'a' => print!("\a"), + //'b' => print!("\b"), + //'c' => print!("\c"), + //'f' => print!("\f"), + 'n' => print!("\n"), + 'r' => print!("\r"), + 't' => print!("\t"), + //'v' => print!("\v"), + '\\' => print!("\\"), + '0' => is_num = true, + _ => print!("\\{c}"), + } + if is_num { + if oc < 3 { + oct.push(c); + oc = oc + 1; + } + if oc == 2 { + match u32::from_str_radix(oct.as_str(), 8) { + Ok(chr) => print!("{}", chr), + Err(_) => print!("\\0{}", oct), + } + is_num = false; + oct = "".to_string(); + oc = 0; + esc = false; + } + } else { + esc = false; + } + } + } + print!("\n"); + */ +} diff --git a/usr/src/mei/echo/src/main.rs b/usr/src/mei/echo/src/main.rs deleted file mode 100644 index ad5eee9..0000000 --- a/usr/src/mei/echo/src/main.rs +++ /dev/null @@ -1,90 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2023 Ren Kararou All rights reserved. - * Use is subject to license terms. - */ - -use std::env; - -fn main() { - let print: String = env::args().skip(1).collect::>().join(" "); - // This does not currently mimic functionality of illumos echo - if print.is_empty() { - println!(""); - } else { - println!("{print}"); - } - - // This mimics illumos echo functionality, or it should - /* - let mut esc: bool = false; - let mut is_num: bool = false; - let mut oct: String = "".to_string(); - let mut oc: u8 = 0; - - for c in print.chars() { - if !esc { - if c == '\\' { - esc = true; - } else { - print!("{c}"); - } - } else { - match c { - // "unknown character escape" wtf rust these are valid. - //'a' => print!("\a"), - //'b' => print!("\b"), - //'c' => print!("\c"), - //'f' => print!("\f"), - 'n' => print!("\n"), - 'r' => print!("\r"), - 't' => print!("\t"), - //'v' => print!("\v"), - '\\' => print!("\\"), - '0' => is_num = true, - _ => print!("\\{c}"), - } - if is_num { - if oc < 3 { - oct.push(c); - oc = oc + 1; - } - if oc == 2 { - match u32::from_str_radix(oct.as_str(), 8) { - Ok(chr) => print!("{}", chr), - Err(_) => print!("\\0{}", oct), - } - is_num = false; - oct = "".to_string(); - oc = 0; - esc = false; - } - } else { - esc = false; - } - } - } - print!("\n"); - */ -} diff --git a/usr/src/mei/printf/Cargo.toml b/usr/src/mei/printf/Cargo.toml index 1dded1e..ac4961b 100644 --- a/usr/src/mei/printf/Cargo.toml +++ b/usr/src/mei/printf/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [[bin]] name = "printf" -path = "src/main.rs" +path = "src/printf.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/usr/src/mei/printf/src/main.rs b/usr/src/mei/printf/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/usr/src/mei/printf/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/usr/src/mei/printf/src/printf.rs b/usr/src/mei/printf/src/printf.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/usr/src/mei/printf/src/printf.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/usr/src/mei/pwd/Cargo.toml b/usr/src/mei/pwd/Cargo.toml index 99a986f..1bc9e99 100644 --- a/usr/src/mei/pwd/Cargo.toml +++ b/usr/src/mei/pwd/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [[bin]] name = "pwd" -path = "src/main.rs" +path = "src/pwd.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/usr/src/mei/pwd/src/main.rs b/usr/src/mei/pwd/src/main.rs deleted file mode 100644 index 051f5bc..0000000 --- a/usr/src/mei/pwd/src/main.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2023 Ren Kararou All rights reserved. - * Use is subject to license terms. - */ - -use std::process::exit; -use std::env::current_dir; - -fn main() { - match current_dir() { - Ok(buf) => { - println!("{}", buf.to_str().unwrap()); - exit(0); - }, - Err(_) => { - eprintln!("pwd: cannot determine current directory!"); - exit(2); - }, - } -} diff --git a/usr/src/mei/pwd/src/pwd.rs b/usr/src/mei/pwd/src/pwd.rs new file mode 100644 index 0000000..051f5bc --- /dev/null +++ b/usr/src/mei/pwd/src/pwd.rs @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2023 Ren Kararou All rights reserved. + * Use is subject to license terms. + */ + +use std::process::exit; +use std::env::current_dir; + +fn main() { + match current_dir() { + Ok(buf) => { + println!("{}", buf.to_str().unwrap()); + exit(0); + }, + Err(_) => { + eprintln!("pwd: cannot determine current directory!"); + exit(2); + }, + } +} diff --git a/usr/src/mei/true/Cargo.toml b/usr/src/mei/true/Cargo.toml index 644bc0d..ec2d8a5 100644 --- a/usr/src/mei/true/Cargo.toml +++ b/usr/src/mei/true/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [[bin]] name = "true" -path = "src/main.rs" +path = "src/true.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/usr/src/mei/true/src/main.rs b/usr/src/mei/true/src/main.rs deleted file mode 100644 index 6f58f4e..0000000 --- a/usr/src/mei/true/src/main.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2023 Ren Kararou All rights reserved. - * Use is subject to license terms. - */ - - -fn main() { - return; -} diff --git a/usr/src/mei/true/src/true.rs b/usr/src/mei/true/src/true.rs new file mode 100644 index 0000000..6f58f4e --- /dev/null +++ b/usr/src/mei/true/src/true.rs @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2023 Ren Kararou All rights reserved. + * Use is subject to license terms. + */ + + +fn main() { + return; +} diff --git a/usr/src/mei/yes/Cargo.toml b/usr/src/mei/yes/Cargo.toml index 8372248..d46dce9 100644 --- a/usr/src/mei/yes/Cargo.toml +++ b/usr/src/mei/yes/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [[bin]] name = "yes" -path = "src/main.rs" +path = "src/yes.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/usr/src/mei/yes/src/main.rs b/usr/src/mei/yes/src/main.rs deleted file mode 100644 index 5a889f0..0000000 --- a/usr/src/mei/yes/src/main.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2023 Ren Kararou All rights reserved. - * Use is subject to license terms. - */ - -use std::env; - -fn main() { - let print: String = env::args().skip(1).collect::>().join(" "); - if print.is_empty() { - loop { - println!("y"); - } - } else { - loop { - println!("{print}"); - } - } -} diff --git a/usr/src/mei/yes/src/yes.rs b/usr/src/mei/yes/src/yes.rs new file mode 100644 index 0000000..5a889f0 --- /dev/null +++ b/usr/src/mei/yes/src/yes.rs @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2023 Ren Kararou All rights reserved. + * Use is subject to license terms. + */ + +use std::env; + +fn main() { + let print: String = env::args().skip(1).collect::>().join(" "); + if print.is_empty() { + loop { + println!("y"); + } + } else { + loop { + println!("{print}"); + } + } +} -- cgit 1.4.1-2-gfad0