Some minor tweaks

This commit is contained in:
Gitea 2020-12-13 14:15:04 -06:00
parent 6731edbf57
commit ae31e82b64
1 changed files with 16 additions and 27 deletions

21
sh.c
View File

@ -1,3 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -6,19 +8,6 @@
#include <signal.h>
#include <libgen.h>
#include <errno.h>
/*
Gods damn it, of course we have to have special shit
just for the fucking GNU Project. Fuckers can't let
anything be done to standard unless they fucking want
to or you beg them to let you, can they?
-Kat
*/
#ifdef __GLIBC__
#define __USE_POSIX
#define __USE_POSIX2
#endif
#include <limits.h>
#define ARG_SEP " " /* Argument separator for commands */
@ -30,19 +19,19 @@ char* prompt();
int cd(char* path);
int main() {
char** argv; /* The command with arguments */
char** argv;
char* user_input;
pid_t child_pid;
int stat_loc; /* ??? (Needed for waitpid) */
signal(SIGINT, SIG_IGN); /* Tell vsh to ignore SIGINT (^C) */
signal(SIGINT, SIG_IGN);
while(1) {
user_input = prompt();
argv = create_argv(user_input);
if(strcmp(argv[0], "cd") == 0) {
if(cd(&user_input[3]) < 0) {
if(cd(argv[1]) < 0) {
perror(argv[1]);
}
/* causes the fork to get skipped */