diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-13 21:45:33 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-13 21:45:33 +0200 |
commit | 48095489b4e1b85f82d80adf69abd691f9bc1679 (patch) | |
tree | c20a6ad7fbe190bde92374a43f3018bf29a7be39 | |
parent | ceb5eba67fff7cc8f85cbb113a86e0c6f349d9db (diff) |
Update README and self-identification.
-rw-r--r-- | README-ZIG.md | 57 | ||||
-rw-r--r-- | README.md | 109 | ||||
-rw-r--r-- | src/eval.zig | 2 |
3 files changed, 110 insertions, 58 deletions
diff --git a/README-ZIG.md b/README-ZIG.md deleted file mode 100644 index d965cd6..0000000 --- a/README-ZIG.md +++ /dev/null @@ -1,57 +0,0 @@ -# Dose - Zig Port - -This is a Zig port of the original Rust-based DOS command shell implementation. - -## Dependency Replacements - -The original Rust version used several external crates that have been replaced with Zig standard library functionality: - -### Rust → Zig Replacements -- **`rustyline`** (command-line editing) → Simple `stdin.readUntilDelimiterOrEofAlloc()` -- **`crossterm`** (terminal manipulation) → ANSI escape sequences for screen clearing -- **`prettytable-rs`** (table formatting) → Custom formatting with `print()` -- **`eyre`/`color-eyre`** (error handling) → Zig's built-in error handling -- **`thiserror`** (error derive macros) → Zig error unions -- **`regex`** (regular expressions) → Not needed in current implementation - -### Key Architectural Changes - -1. **Error Handling**: Replaced Rust's `Result<T, E>` with Zig's error unions (`!T`) -2. **Memory Management**: Manual allocation/deallocation using Zig's allocators instead of Rust's ownership system -3. **String Handling**: Explicit memory management for strings vs Rust's `String`/`&str` -4. **Concurrency**: Removed complex threading from original Rust version for simplicity -5. **Command Line Editing**: Simplified to basic line reading (no history or editing features) - -### Missing Features (compared to Rust version) -- Command-line history and editing (rustyline features) -- Colored error output -- Advanced terminal manipulation -- Complex pipe/redirection handling -- Multi-threaded command execution - -## Build Instructions - -```bash -# Build and run in debug mode -zig build run - -# Build optimized release version -zig build -Doptimize=ReleaseFast - -# Run tests -zig build test -``` - -## Implementation Notes - -The Zig version focuses on core DOS command functionality while maintaining the same architectural patterns as the Rust original. The enum-based command system has been preserved using Zig's union types. - -Key DOS commands implemented: -- `ECHO` (with ON/OFF variants) -- `CLS` (clear screen) -- `EXIT` (exit shell) -- `VER` (version info) -- `DATE` and `TIME` (system date/time) -- `DIR` (directory listing) - -The implementation uses Zig's standard library exclusively, avoiding external dependencies for better portability and simplicity. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c3e4638 --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +# DOS-Like Shell (Zig) + +A small DOS-inspired shell implemented in Zig. It aims to reproduce the feel of classic MS-DOS utilities and behaviors, including 8.3 filename formatting, backslash paths, simple prompts, and a subset of built-in commands. + +This project is educational and intentionally simplified; it is not a full DOS emulator or a drop-in replacement for CMD. + +## Features + +- DOS-style prompt with basic variables: + - `$p` current path (formatted in DOS style) + - `$g` greater-than character (`>`) +- Path handling: + - Converts `/` to `\` and uppercases drive letters and names + - Formats individual path segments to 8.3-style names where applicable + - Defaults to `C:` when no drive is present +- Built-in commands (subset): + - `ECHO` (plain and text) + - `CLS` + - `EXIT` + - `VER` + - `DATE` and `TIME` (simplified calculations/formatting) + - `DIR` (lists files/directories with simplified date/time and sizes) + - `TYPE` (prints file contents with basic character handling) + - `SORT` (reads from redirected input and prints sorted lines) + - `CD`/`CHDIR` (change directory; basic cases like `..` and root) + - `COPY` (file copy; also supports `COPY CON destination` for interactive input until Ctrl+Z) + - `DEL`/`ERASE` (file removal; no wildcards yet) + - `MKDIR`/`MD` (make directory) +- Redirection: + - Input: `< file` + - Output overwrite: `> file` + - Output append: `>> file` +- External command execution: + - Executes programs in your environment when not matched by a built-in + +## Limitations + +- Simplified date/time and calendar calculations +- No full wildcard support (e.g., in `DEL`) +- Device names (`CON`, `PRN`, `LPTx`) are recognized in limited contexts +- Not a complete DOS environment; behavior is “DOS-like” rather than exact + +## Build + +Requirements: +- Zig (recent version) + +Build: + +``` +zig build +``` + +This produces an executable in `zig-out/bin`. + +## Run + +Start the shell: + +``` +zig-out/bin/dose +``` + +You’ll see a DOS-like prompt. Example interactions: + +``` +C:\> VER +DOSE Version 6.22 +C:\> DIR +... directory listing ... +C:\> COPY CON hello.txt +Hello world! +^Z + 1 File(s) copied +C:\> TYPE hello.txt +Hello world! +``` + +Redirection: + +``` +C:\> DIR > dir.txt +C:\> TYPE dir.txt +``` + +Change directory: + +``` +C:\> CD .. +C:\> DIR +``` + +## Development Notes + +- The shell uses a simple parser and a set of built-in command handlers. +- Paths shown to the user are normalized to DOS conventions (uppercase, backslashes, and 8.3-style segments). +- External commands are executed via the host OS process APIs; errors are reported in a DOS-like manner. + +## Roadmap + +- Wildcards for file operations +- More built-in commands and switches +- Improved date/time correctness +- Better device/file semantics +- Enhanced error messages and testing + +## License + +GNU AGPLv3. diff --git a/src/eval.zig b/src/eval.zig index aeebba3..6c9a449 100644 --- a/src/eval.zig +++ b/src/eval.zig @@ -163,7 +163,7 @@ fn executeCommandWithOutput(command: Command, allocator: Allocator, output_captu return CommandStatus{ .Code = 0 }; }, .Ver => { - const output = "MS-DOS Version 6.22 (Zig Implementation)\n"; + const output = "DOSE Version 6.22\n"; if (output_capture) |capture| { try capture.write(output); } else { |