summaryrefslogtreecommitdiffstats
path: root/bins/cat/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-01 15:52:39 +0100
committersalmonik <salmonik@tuta.io>2026-11-01 15:52:39 +0100
commitef2d8e354a91ef30e34e2ddb61381131a989591c (patch)
tree6a5e46da58f3371e430354d5352b6675d6076c39 /bins/cat/src
parentbuild: default profile is release (debug too slow for dev loop) (diff)
downloadrs-dos-ef2d8e354a91ef30e34e2ddb61381131a989591c.tar.gz
rs-dos-ef2d8e354a91ef30e34e2ddb61381131a989591c.zip
bins: read user args from argv[1..]; fix date year digit
exec::spawn passes C-style argv with argv[0] = the command name, but ls, cat, mkdir, touch and rm treated argv[0] as their first user argument. Every path they were given resolved to the literal command name ("ls", "mkdir", ...), so they failed silently: `mkdir .../sub` never created the directory, `cat` printed nothing. date formatted its last year digit as `y as u8 % 10`, which truncates before the modulo (2026 -> 234 -> '4'), printing "2024". Only visible now that the system image actually stages /bin — before, /bin was empty and every command fell back to a built-in.
Diffstat (limited to 'bins/cat/src')
-rw-r--r--bins/cat/src/main.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/bins/cat/src/main.rs b/bins/cat/src/main.rs
index 6683c83..f530525 100644
--- a/bins/cat/src/main.rs
+++ b/bins/cat/src/main.rs
@@ -37,8 +37,9 @@ fn dump_file(exports: &rsapi::Exports, path: &str) -> i32 {
37 37
38#[unsafe(no_mangle)] 38#[unsafe(no_mangle)]
39pub extern "C" fn efi_main(exports: &'static rsapi::Exports, argc: usize, argv: *const rsapi::Arg) -> i32 { 39pub extern "C" fn efi_main(exports: &'static rsapi::Exports, argc: usize, argv: *const rsapi::Arg) -> i32 {
40 let args = unsafe { core::slice::from_raw_parts(argv, argc) }; 40 // C-style argv: argv[0] is the program name, user args start at 1.
41 if argc > 0 { 41 let args = unsafe { core::slice::from_raw_parts(argv.add(1), argc.saturating_sub(1)) };
42 if !args.is_empty() {
42 // Print each path argument 43 // Print each path argument
43 let mut code = 0; 44 let mut code = 0;
44 for a in args.iter() { 45 for a in args.iter() {