Skip to content

Instantly share code, notes, and snippets.

@gdisneyleugers
Created August 14, 2014 19:17
Show Gist options
  • Save gdisneyleugers/0f0de83778afd03fe71c to your computer and use it in GitHub Desktop.
Save gdisneyleugers/0f0de83778afd03fe71c to your computer and use it in GitHub Desktop.
#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 -lgtk */
int shell(void)
{
rl_bind_key('\t', rl_complete);
const char *b[4096];
const char *a = fgets("shell->", *b, 4096);
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(1) {
exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment