- Cross-compiled Go-based shell for Windows (PE32+ executable) - Builtins: cd, pwd, echo, exit, export, source, alias, type - Coreutils: ls, cat, grep, sort, wc, head, find, cp, mv, rm, mkdir, touch, clear - Command chaining: &&, ||, ; - Pipes between builtins and external commands - Variable expansion (, ) and assignment (NAME=VALUE) - Tokenizer with single/double quote handling - Linux and Windows (x86_64) builds via build.sh
63 lines
1.5 KiB
Markdown
63 lines
1.5 KiB
Markdown
# bash-for-windows
|
|
|
|
A fully functional bash shell for Windows, written in Go. Run bash commands and scripts natively on Windows without WSL, Cygwin, or MSYS2.
|
|
|
|
## Features
|
|
|
|
- **Interactive shell** with prompt (`bash$`)
|
|
- **Built-in commands**: cd, pwd, echo, exit, export, source, alias, type
|
|
- **Built-in coreutils**: ls, cat, grep, sort, wc, head, find, cp, mv, rm, mkdir, touch, clear
|
|
- **Command chaining**: `&&`, `||`, `;`
|
|
- **Pipes**: `|` between commands
|
|
- **Variable expansion**: `$NAME`, `${NAME}`
|
|
- **Variable assignment**: `NAME=VALUE command`
|
|
- **Single & double quotes**: `'literal'`, `"$variable"`
|
|
- **Script execution**: `bash-windows script.sh` or `-c 'commands'`
|
|
- **No dependencies** — single `.exe` file, runs on any Windows x86-64
|
|
|
|
## Usage
|
|
|
|
```
|
|
bash-windows # Interactive mode
|
|
bash-windows -c 'echo hello'
|
|
bash-windows script.sh
|
|
```
|
|
|
|
### Examples
|
|
|
|
```
|
|
bash$ echo "Hello from bash-for-windows!"
|
|
bash$ ls -la
|
|
bash$ cd /tmp && pwd
|
|
bash$ cat file.txt | grep pattern | wc -l
|
|
bash$ name="Luffy" && echo $name
|
|
bash$ mkdir -p project/src && touch project/src/main.go
|
|
```
|
|
|
|
## Building
|
|
|
|
Requires Go 1.21+.
|
|
|
|
```bash
|
|
# Linux
|
|
./build.sh
|
|
|
|
# Manual
|
|
go build -o build/bash-windows .
|
|
|
|
# Windows cross-compile
|
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o build/bash-windows.exe .
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
cmd/bash/ - Shell entry point
|
|
internal/shell/ - Shell engine (parser, executor, builtins, coreutils)
|
|
build/ - Compiled binaries
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|