{"id":27779898,"url":"https://github.com/luckykk273/kysh","last_synced_at":"2026-05-19T04:13:30.213Z","repository":{"id":290287606,"uuid":"972365867","full_name":"luckykk273/kysh","owner":"luckykk273","description":"A simple shell in C.","archived":false,"fork":false,"pushed_at":"2025-05-12T08:36:24.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T09:07:31.552Z","etag":null,"topics":["c","pipeline","redirection","shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luckykk273.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-25T00:53:50.000Z","updated_at":"2025-05-12T08:36:28.000Z","dependencies_parsed_at":"2025-04-30T10:56:13.962Z","dependency_job_id":"8cf3cafe-77a5-4825-9412-a1a7c2c0241b","html_url":"https://github.com/luckykk273/kysh","commit_stats":null,"previous_names":["luckykk273/kysh"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/luckykk273/kysh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckykk273%2Fkysh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckykk273%2Fkysh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckykk273%2Fkysh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckykk273%2Fkysh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckykk273","download_url":"https://codeload.github.com/luckykk273/kysh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckykk273%2Fkysh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33201543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"online","status_checked_at":"2026-05-19T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","pipeline","redirection","shell"],"created_at":"2025-04-30T10:56:03.890Z","updated_at":"2026-05-19T04:13:30.195Z","avatar_url":"https://github.com/luckykk273.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kysh\nA simple shell in C.\n\n## Preface\nThis repository was originally created by following the [website tutorial](https://brennan.io/2015/01/16/write-a-shell-in-c/), and later had some additional features added (e.g. tokenizer, multiple pipes and I/O redirections). There are some known errors, but in most cases, it runs well enough. Since this repo is just intended to help with understanding some important [concepts](#key-concepts), these errors **WON'T** be fixed for now.\n\n## Usage\n### Build and run\n```bash\n$ make\n$ ./build/kysh\nkysh\u003e\n```\n\n## Key Concepts\n1. How a simple shell work\n2. How to use the system call in C\n    - pipes (`fork()`, `pipe()`, `execvp()`, `close()`, ...)\n    - redirections (`open()`, `close()`, `dup2()`, ...)\n3. How to tokenize the command line\n    - Tokenize by delimiters: `' '`, `'\\t'`, `'\\r'`, `'\\n'`, `'\\a'`\n    - Handle special delimiters for pipes and I/O redirection: `'|'`, `'\u003c'`, `'\u003e'`  \n      NOTE: **NO** standard error supported (No `2\u003e`, `\u003e\u0026`, `\u0026\u003e`, `2\u003e\u00261`)\n4. Linked list (`command_t`, `redirection_t`)\n\n## Tests\nIf someone wants to see the results only, run `kysh` and enter the commands manually.  \nNOTE: The behaviors in `kysh` should be the **SAME** as in `Bash`  \n\nIf someone wants to see the details of how `kysh` works, run the test functions in `tests/test.c`.\n\n### Run the test functions\n```bash\n$ cd tests\n$ make\n$ ./build/test\n```\n\n### Run the commands manually\n**Multiple pipes only**\n```bash\nkysh\u003e ls -al | rev | nl | cat -e\n```\n\n**Multiple pipes with builtin function**\n```bash\nkysh\u003e cd .. | echo hello | echo world\nkysh\u003e echo hello | cd .. | echo world\nkysh\u003e echo hello | echo world | cd ..\n```\n\n**Multiple redirections only**\n```bash\nkysh\u003e echo hello \u003e out1 \u003e out2\nkysh\u003e ls -l \u003e file1 -a \u003e file2\nkysh\u003e grep main \u003c ./src/main.c \u003e out\n```\n\n**Multiple redirections with multiple pipes**\n```bash\nkysh\u003e echo Kyle 87 \u003e in1.txt  | echo Dog 88 \u003e in2.txt | grep Kyle \u003e out.txt \u003c in2.txt \u003c in1.txt\n```\n\n**Error catch**\n```bash\nkysh\u003e cd..\nkysh\u003e cd.. | ls\n```\n\n**Arbitrary whitespaces between commands and delimiters**\n```bash\nkysh\u003e echo hello     | ls\nkysh\u003e echo hello|      ls\nkysh\u003e echo hello\u003e         hello.txt|   ls\nkysh\u003e echo hello         \u003ehello.txt   |ls\nkysh\u003e ls     -al    |rev  | nl |cat    -e\n```\n\n## Reference\n1. [Tutorial - Write a Shell in C](https://brennan.io/2015/01/16/write-a-shell-in-c/)\n2. [GitHub - lsh](https://github.com/brenns10/lsh)\n3. [GitHub Gist - pipex.c](https://gist.github.com/iomonad/a66f6e9cfb935dc12c0244c1e48db5c8)\n4. [CS 702 - Operating Systems - Spring 2005 - Using dup2 for I/O Redirection and Pipes](https://www.cs.loyola.edu/~jglenn/702/S2005/Examples/dup2.html)\n4. [GNU Bash Manual - 3.6 Redirections](https://www.gnu.org/software/bash/manual/html_node/Redirections.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckykk273%2Fkysh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckykk273%2Fkysh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckykk273%2Fkysh/lists"}