Skip to content

Commit

Permalink
some uptdate for printing
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoussaoui authored and nmoussaoui committed Sep 1, 2022
1 parent 8a4bba2 commit 8163d3b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
10 changes: 3 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
#include <stdbool.h>
#include <signal.h>

/* Le shell fonctionne normalement bien pour toutes les fonctionnalités sauf
bg pose problème.
Pour fg le procesuss est bien réveillé au vu de htop et on l'a au premier plan.
Par cotnre pour bg c'est totalement aléatoire avec le code que j'ai fait */

static void handler(int sig){

Expand All @@ -24,7 +20,7 @@ static void handler(int sig){

}
static void sigttin_hand(int sig){
printf("%d\n",getpid());
//printf("%d\n",getpid());
kill(getpid(),SIGSTOP);
}

Expand Down Expand Up @@ -59,7 +55,7 @@ int main(int argc , char** argv){

if(getenv("pid_father")==NULL){
int fd=open("pid_list",O_CREAT|O_TRUNC,0644);
printf("%d\n",fd);
//printf("%d\n",fd);
close(fd);

}
Expand Down Expand Up @@ -109,7 +105,7 @@ int main(int argc , char** argv){
if(( out=(char*)malloc(100))==NULL)error("malloc failed",EXIT_FAILURE);

getcwd(dir,124);
printf("%s$:\n ",dir);
printf(" \x1B[32m%s$:\x1B[0m\n ",dir);
line[nb-1]=0;
scan_and_replace('>',&line);
scan_and_replace('<',&line);
Expand Down
Binary file added main.o
Binary file not shown.
Empty file added pid_list
Empty file.
Binary file added shell
Binary file not shown.
8 changes: 4 additions & 4 deletions shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int len_ptr ( char* s[]){
}


void affiche_cmd(char* argv[]){
void display_cmd(char* argv[]){
int i=0;
while(argv[i]){
if(argv[i+1]==NULL){
Expand Down Expand Up @@ -376,13 +376,13 @@ int parse_line_pipes(char* s,char**** argv,char** in,char** out){



void affiche_cmd_piped(char *** argv){
void display_cmd_piped(char *** argv){
int i=0;
printf("{");
while(argv[i]){
printf("[");

affiche_cmd(argv[i]);
display_cmd(argv[i]);
printf("]");
i++;
}
Expand Down Expand Up @@ -429,7 +429,7 @@ void redir_cmd_1(char** argv, char*in, char* out){
}
temp[k]=0;
dup2(fdin,STDIN_FILENO);
affiche_cmd(temp);
display_cmd(temp);
printf("\n");
simple_cmd(temp);
close(fdin);
Expand Down
4 changes: 2 additions & 2 deletions shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@


void simple_cmd(char** argv);
void affiche_cmd(char* argv[]);
void display_cmd(char* argv[]);
int parse_line_redir(char* s,char** argv[],char** in,char** out);
int parse_line(char* s,char*** argv);
void free_argv(char** argv[]);
void exec_bash(int fdesc);
void redir_cmd_1(char** argv, char*in, char* out);
void redir_cmd(char *** argv, char* in,char* out);
void affiche_cmd_piped(char *** argv);
void display_cmd_piped(char *** argv);
int parse_line_pipes(char* s,char*** argv[],char** in,char** out);
void free_argv_2(char **** argv);

Expand Down
Binary file added shell.o
Binary file not shown.

0 comments on commit 8163d3b

Please sign in to comment.