From: Trent Huber Date: Mon, 23 Jun 2025 14:15:12 +0000 (-0400) Subject: Updated README.md X-Git-Url: https://trenthuber.com/code?a=commitdiff_plain;h=f7bbe034ef81157f25552b4577b6313a404f9135;p=thus.git Updated README.md --- diff --git a/.gitignore b/.gitignore index 3ac8fc1..378eac2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -*.o -ash build diff --git a/README.md b/README.md index f0fae1a..c36531c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,42 @@ # Ash +While Unix shells are a solved problem in computer science, recent iterations have admittedly been more and more complicated by feature sets that attempt to cater to all users. Ash seeks to be a completely stripped down, simplified approach to shells, only including the essential parts, i.e., just the things *I personally use*. In fact, the main goals for this project in order or priority have been: + +1. To learn more about the interaction between shells, terminals, and the operating system. +2. To create a utility I would personally want to use. +3. To create a utility other people would want to use. + +## Feature Set + +- Foreground and background process groups (`fg`, `bg`, `&`) +- Unix pipes +- Conditional execution (`&&`, `||`) +- Shell history (cached in `~/.ashhistory`) + +### Future features + +- File redirection +- Environment variables +- Scripting +- File globbing + +## Building + +Similar to my other projects, ash uses [cbs](https://github.com/trenthuber/cbs) as its build system, included as a git submodule, so make sure to clone recursively. + +```console +$ git clone --recursive https://github.com/trenthuber/ash +$ cd ash +$ cc -o build build.c +$ ./build +$ ./bin/ash +``` + +Note, you only need to run the `cc` command the first time you build the project, as the `./build` executable will recompile itself everytime it is run. + ## Resources +These websites have been invaluable in the making of ash. + - [TTY Demystified](http://www.linusakesson.net/programming/tty/) - [Process Groups and Terminal Signaling](https://cs162.org/static/readings/ic221_s16_lec17.html) diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..229a8d2 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +ash diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..5761abc --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/src/job.c b/src/job.c index 4125d2d..a5f366e 100644 --- a/src/job.c +++ b/src/job.c @@ -13,12 +13,6 @@ static struct job jobarray[MAXJOBS + 1]; struct stack INITSTACK(jobs, jobarray, 0); -void sigkill(pid_t jobid) { - if (killpg(jobid, SIGKILL) == -1) - warn("Unable to kill process group %d; manual termination may be required", - jobid); -} - void *findjob(pid_t jobid) { if (jobs.b == jobs.t) return NULL; for (jobs.c = jobs.b; CURRENT->id != jobid; INC(jobs, c)) diff --git a/src/job.h b/src/job.h index 4034cfc..73b2ed1 100644 --- a/src/job.h +++ b/src/job.h @@ -12,7 +12,6 @@ struct job { #define CURRENT ((struct job *)jobs.c) extern struct stack jobs; -void sigkill(pid_t jobid); void *findjob(pid_t jobid); void *deletejob(void); void waitbg(int sig); diff --git a/src/term.c b/src/term.c index 52ec184..c703d34 100644 --- a/src/term.c +++ b/src/term.c @@ -57,6 +57,12 @@ quit: exit(EXIT_FAILURE); } +static void sigkill(pid_t jobid) { + if (killpg(jobid, SIGKILL) == -1) + warn("Unable to kill process group %d; manual termination may be required", + jobid); +} + int setfg(struct job job) { if (tcsetattr(STDIN_FILENO, TCSANOW, &job.config) == -1) warn("Unable to set termios structure");