#include #include #include #include #include int main(void) { char buf[256]; char *args[64]; while (1) { printf("%s ", getuid() ? "$" : "#"); fflush(stdout); if (!fgets(buf, sizeof(buf), stdin)) break; buf[strcspn(buf, "\n")] = 0; if (!buf[0]) continue; if (!strcmp(buf, "exit")) break; int i = 0; char *tok = strtok(buf, " "); while (tok && i < 63) args[i++] = tok, tok = strtok(NULL, " "); args[i] = NULL; if (fork() == 0) execvp(args[0], args), perror("exec"), exit(1); else wait(NULL); } }