commit 81f70044a06a0476861069ad52a640fdbb8def5a
parent 8789d30c38aaee6192cd5c05ea2ec3ff862c6019
Author: night0721 <[email protected]>
Date: Fri, 16 Feb 2024 13:45:35 +0000
delete comments and add usage in readme
Diffstat:
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
@@ -4,25 +4,34 @@ rush is a minimalistic shell for Unix systems written in C.
* Disclaimer: This project is for me to learn to write Unix syscalls, code might be inefficient, feel free to point out the mistakes and open a issue for that!
-# Preview
+## Preview
[![Valid command](https://r2.e-z.host/3c62bb3a-a8a9-43f6-afd6-553646f51dc4/aqnpvvud.png)]()
[![Invalid command](https://r2.e-z.host/3c62bb3a-a8a9-43f6-afd6-553646f51dc4/xf80dq0b.png)]()
-# Dependencies
+## Dependencies
- gcc
-# Building
+## Building
```sh
$ make
$ sudo make install
```
-# Usage
+## Usage
```sh
$ ./rush
+
+# > to redirect stdout
+# < to redirect stdin
+# 2> to redirect stderr
+# >> to append to file
+# & to run command in background
+# | to pipe
+# !! to repeat last command
+# >& to redirect both stdout and stderr
```
-# Features
+## Features
- No dependencies except a compiler
- Showing current time and directory with custom color
- Syntax highlighting on valid commands using ANSI colors
@@ -35,7 +44,7 @@ $ ./rush
- stdin, stdout, stderr redirect
- Background jobs
-# Built in commands
+## Built in commands
- cd
- help
- exit
@@ -45,12 +54,14 @@ $ ./rush
- j
- bg
-# Todo Features
+## Todo Features
- Tab completion
- Git integration
- Allow arguments with space in double quotes
+- Underline file path if it exists
+- Aliases
-# Credits
+## Credits
- [Tutorial - Write a shell in C](https://brennan.io/2015/01/16/write-a-shell-in-c/)
- [dash](https://github.com/danishprakash/dash)
- [Shell assignment](https://www.cs.cornell.edu/courses/cs414/2004su/homework/shell/shell.html)
diff --git a/commands.c b/commands.c
@@ -207,8 +207,6 @@ int export(char **args) {
return 0;
}
} else {
- printf("rush: [arg0: %s] [arg1: %s]", args[0], args[1]);
- printf("rush: [Variable: %s] [Value: %s]\n", variable, value);
fprintf(stderr, "rush: Syntax error when setting environment variable\nUse \"export VARIABLE=VALUE\"\n");
return 0;
}
@@ -418,14 +416,12 @@ int execute_pipe(char ***args) {
while (args[num_cmds] != NULL) {
int num_args = 0;
while (args[num_cmds][num_args] != NULL) {
- //printf("args [%i]: %s\n", num_cmds, args[num_cmds][num_args]);
num_args++;
}
num_cmds++;
}
for (int i = 0; i < num_cmds - 1; i++) {
- //printf("i: %d\n", i);
pipe(pipefd);
if ((pid = fork()) == 0) {
// then this (child)
@@ -445,7 +441,6 @@ int execute_pipe(char ***args) {
}
if ((pid = fork()) == 0) {
- // printf("last command\n");
dup2(in, STDIN_FILENO); // get input from pipe
execute(args[num_cmds - 1]);
exit(EXIT_SUCCESS);
diff --git a/job.c b/job.c
@@ -54,9 +54,7 @@ job *get_job(int index) {
return NULL;
}
for (int i = 0; i < index; i++) {
- printf("current: %s\n", current->command);
current = current->next;
- printf("next: %s\n", current->command);
}
return current;
}