Repository navigation
Commands rm
Frank edited this page Apr 17, 2026
·
1 revision
Remove (delete) files from the filesystem.
rm <file1> [file2] [file3] ...
rm removes (deletes) one or more files from the filesystem. The command accepts multiple filenames as arguments and will attempt to delete each one.
Warning: Deleted files cannot be recovered! Use with caution.
-
file1, file2, ...: One or more files to delete. Paths can be absolute or relative to the current working directory.
For each file, rm will either successfully delete it or report an error:
- Success: File is removed from the filesystem
-
Error codes:
-
-2: No such file or directory -
-13: Permission denied -
-21: Is a directory (usermdirfor directories) - Other: Error code number displayed
-
> rm test.txt
> rm file1.txt file2.txt file3.txt
Removed 3 files
> rm nonexistent.txt
rm: cannot remove 'nonexistent.txt': No such file or directory
> rm good.txt bad.txt another.txt
rm: cannot remove 'bad.txt': No such file or directory
Removed 2 files, 1 error
rm is implemented in CupidC (/bin/rm.cc) and demonstrates:
Custom parse_token() function to split space-separated arguments:
int parse_token(char *str, int start, char *out, int maxlen) {
// Skip whitespace, extract token, return length
}This function handles:
- Leading/trailing whitespace
- Multiple arguments in a single string
- Null termination
Uses vfs_unlink(path) syscall to delete files:
int result = vfs_unlink(path);
if (result == 0) {
// Success
} else {
// Handle error codes
}Comprehensive error reporting with human-readable messages for common POSIX error codes.
/bin/rm.cc
- vfs_unlink - VFS unlink syscall
- CupidC Language Reference
-
ls- List directory contents -
cat- Display file contents
- Cannot remove directories (use
rmdirinstead) - No
-rrecursive flag (yet) - No
-fforce flag (yet) - No wildcard support (yet)
-
1.0.0 - Initial CupidC implementation
- Multi-file deletion support
- Path resolution
- Error code handling with human-readable messages
- Summary output for multiple files
Getting Started
Shell & Scripting
Compilers
- CupidC Compiler
- CupidC Language Reference
- CupidC 2D Graphics Library
- CupidASM Assembler
- Toolchain Bootstrap
- Floating Point
Programs & Docs
GUI
Kernel
Filesystems
Hardware