delete comments and add usage in readme

This commit is contained in:
Night Kaly 2024-02-16 13:45:35 +00:00
parent 8789d30c38
commit 81f70044a0
No known key found for this signature in database
GPG key ID: 8E829D3381CFEBBE
3 changed files with 19 additions and 15 deletions

View file

@ -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)

View file

@ -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);

2
job.c
View file

@ -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;
}