Skip to content
This repository was archived by the owner on Jan 4, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Bun Shell

操作系统专题实践课程作业

这是一个使用 TypeScript 和 Bun 构建的轻量级 Shell 实现。旨在演示基本的 Shell 原理,包括进程管理、管道和重定向。

功能特性

  • 基础命令执行: 支持执行标准的系统命令(如 ls, grep, echo 等)。
  • 内建命令:
    • cd [dir]: 切换当前工作目录。
    • exit [code]: 退出 shell(支持指定退出码,默认为 0)。
  • 管道 (|): 支持将一个命令的输出作为下一个命令的输入。
  • 重定向:
    • < file: 输入重定向。
    • > file: 输出重定向(覆盖)。
    • >> file: 输出重定向(追加)。
  • 后台运行 (&): 支持在后台异步执行命令。
  • 动态提示符: 实时显示当前工作目录(支持 ~ 缩写)。

快速开始

前置要求

本项目依赖 Bun 运行时。请确保已安装 Bun。

运行

  1. 克隆或进入项目目录。
  2. 启动 Shell:
bun shell

使用示例

# 列出文件
mini ~/my-shell$ ls -la

# 写入文件并读取
mini ~/my-shell$ echo "Hello World" > hello.txt
mini ~/my-shell$ cat hello.txt
Hello World

# 管道操作
mini ~/my-shell$ cat hello.txt | grep "Hello"
Hello World

# 切换目录
mini ~/my-shell$ cd ..
mini ~/my-project$ 

# 退出
mini ~/my-project$ exit

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages