mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-24 10:04:20 +00:00
Merge branch 'sli' into 'master'
Perfect logic is perfect and beyond perfection since there is no memory leak See merge request !8
This commit is contained in:
commit
99b847d43a
@ -33,9 +33,11 @@ builtinCommand **getBuiltinCommands(){
|
|||||||
int fishCd(WordArray *args) {
|
int fishCd(WordArray *args) {
|
||||||
if (args->size < 2){
|
if (args->size < 2){
|
||||||
fprintf(stderr, "fish: Où sont les arguments de ta commande \"cd\" connard ?!\n");
|
fprintf(stderr, "fish: Où sont les arguments de ta commande \"cd\" connard ?!\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
if (chdir(args->words[1]) != 0){
|
if (chdir(args->words[1]) != 0){
|
||||||
perror("fish");
|
perror("fish");
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeWordArray(args);
|
freeWordArray(args);
|
||||||
|
@ -156,33 +156,38 @@ int fishExecute(WordList *list) {
|
|||||||
int signal = 1;
|
int signal = 1;
|
||||||
|
|
||||||
splited = parseWordList(list, &op);
|
splited = parseWordList(list, &op);
|
||||||
array = wordListToWordArray(list);
|
|
||||||
|
|
||||||
signal = loadRightCommand(array);
|
|
||||||
if (signal == EXIT_SIGNAL){
|
|
||||||
if (splited != NULL) freeWordList(splited);
|
|
||||||
if (array != NULL) freeWordArray(array);
|
|
||||||
return signal;
|
|
||||||
}
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case AND:
|
case AND:
|
||||||
|
signal = fishExecute(list);
|
||||||
if (!signal) signal = fishExecute(splited);
|
if (!signal) signal = fishExecute(splited);
|
||||||
else {
|
else {
|
||||||
if (splited != NULL) freeWordList(splited);
|
if (splited != NULL) freeWordList(splited);
|
||||||
|
splited = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REVERSE_AND:
|
case REVERSE_AND:
|
||||||
if (signal) signal = fishExecute(splited);
|
signal = fishExecute(list);
|
||||||
|
if (signal && signal != EXIT_SIGNAL) signal = fishExecute(splited);
|
||||||
else {
|
else {
|
||||||
if (splited != NULL) freeWordList(splited);
|
if (splited != NULL) freeWordList(splited);
|
||||||
|
splited = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OR:
|
case OR:
|
||||||
signal = fishExecute(splited);
|
signal = fishExecute(list);
|
||||||
|
if (signal != EXIT_SIGNAL) signal = fishExecute(splited);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
array = wordListToWordArray(list);
|
||||||
|
signal = loadRightCommand(array);
|
||||||
|
splited = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (signal == EXIT_SIGNAL){
|
||||||
|
if (splited != NULL) freeWordList(splited);
|
||||||
|
if (array != NULL) freeWordArray(array);
|
||||||
|
}
|
||||||
|
|
||||||
return signal;
|
return signal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user