progress on shell
This commit is contained in:
parent
8a63095163
commit
c6cab81a01
2 changed files with 46 additions and 5 deletions
BIN
shell2
BIN
shell2
Binary file not shown.
51
shell2.c
51
shell2.c
|
|
@ -1,15 +1,56 @@
|
|||
#include<stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#define clear() printf("\033[H\033[J")
|
||||
|
||||
void init_shell() {
|
||||
clear();
|
||||
printf("\n\n\n\n******************"
|
||||
"************************");
|
||||
|
||||
printf("\n\n\n\n******************************************");
|
||||
printf("\n\n\n\t****MY SHELL****");
|
||||
printf("\n\n\t-USE AT YOUR OWN RISK-");
|
||||
printf("\n\n\n\n*******************"
|
||||
"***********************");
|
||||
printf("\n\n\n******************************************");
|
||||
|
||||
char* username = getenv("USER");
|
||||
printf("\n\nUSER is: @%s\n", username);
|
||||
sleep(1);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
int take_input(char* str) {
|
||||
char* buf;
|
||||
|
||||
buf = readline("\n>>> ");
|
||||
if(strlen(buf) != 0) {
|
||||
add_history(buf);
|
||||
strcpy(str, buf);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void print_dir() {
|
||||
char cwd[1024];
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
printf("\nDir: %s", cwd);
|
||||
}
|
||||
|
||||
def execute(char** parsed) {
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid == -1) {
|
||||
printf("\nFailed forking child..");
|
||||
return;
|
||||
} else if (pid == 0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue