Skip to content

Instantly share code, notes, and snippets.

@gdisneyleugers
Created July 24, 2014 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdisneyleugers/6e1b71cc1bee4a3b9eee to your computer and use it in GitHub Desktop.
Save gdisneyleugers/6e1b71cc1bee4a3b9eee to your computer and use it in GitHub Desktop.
Simple shell I worte in C
#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