blob: c3e4638f14eb40668033188371d8bcb383b4ad87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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.
|