Created
July 24, 2014 23:14
-
-
Save gdisneyleugers/6e1b71cc1bee4a3b9eee to your computer and use it in GitHub Desktop.
Simple shell I worte in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <readline/readline.h> | |
#include <readline/history.h> | |
/* to compile run gcc shell.c -o shell -Wformat-security -Wint-conversion -Wincompatible-pointer-types -lreadline */ | |
int shell(void) | |
{ | |
rl_bind_key('\t', rl_complete); | |
const char *b[4096]; | |
const char *a = gets(&b); | |
char *f = readline("shell-> "); | |
char ex = 'exit'; | |
if (f == ex ) { | |
exit(0); | |
} | |
const char *d = system(f); | |
return(0); | |
} | |
int main(void) | |
{ | |
while(1) | |
shell(); | |
return(0); | |
if(0) { | |
exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment