@ -5,6 +5,9 @@
@@ -5,6 +5,9 @@
# include <dirent.h>
# include <readline/readline.h>
# include <readline/history.h>
int get_alias ( Alias * alias , State * state , char * name ) ;
int add_alias ( State * state , char * name , char * substitution ) ;
int del_alias ( State * state , char * name ) ;
@ -113,7 +116,6 @@ int del_array_element(GrowingArray* array, char* key) {
@@ -113,7 +116,6 @@ int del_array_element(GrowingArray* array, char* key) {
} else {
array - > inner [ i ] = array - > inner [ i + 1 ] ;
}
}
}
}
@ -203,7 +205,6 @@ void shutdown(State *state) {
@@ -203,7 +205,6 @@ void shutdown(State *state) {
}
int check_pipes ( State * state , int num_args , char * args [ ] ) {
int left = 0 ;
int num_commands = 0 ;
int space = 10 ;
@ -256,13 +257,8 @@ int check_pipes(State* state, int num_args, char* args[]) {
@@ -256,13 +257,8 @@ int check_pipes(State* state, int num_args, char* args[]) {
for ( int i = 0 ; i < num_commands ; i + + ) {
execute ( in , out , pipes [ i ] , & child ) ;
if ( i ! = num_commands - 1 ) {
if ( in = = pipein [ 0 ] ) {
in = pipeout [ 0 ] ;
out = pipein [ 1 ] ;
} else {
in = pipein [ 0 ] ;
out = pipeout [ 1 ] ;
}
in = pipeout [ 0 ] ;
out = pipein [ 1 ] ;
} else {
out = 1 ;
in = out - 1 ;
@ -324,7 +320,6 @@ int check_builtins(State *state, int num_args, char *args[]) {
@@ -324,7 +320,6 @@ int check_builtins(State *state, int num_args, char *args[]) {
}
}
return ER_FAILURE ;
}
if ( ! strcmp ( args [ 0 ] , " alias " ) ) {
@ -459,11 +454,12 @@ int repl(State* state, FILE *input) {
@@ -459,11 +454,12 @@ int repl(State* state, FILE *input) {
char * line ;
if ( state - > interactive ) {
fprintf ( state - > output , " %s " , state - > ps1 ) ;
}
if ( readline ( input , & line ) ) {
return ER_SUCCESS ;
line = readline ( state - > ps1 ) ;
add_history ( line ) ;
} else {
if ( get_line ( input , & line ) ) {
return ER_SUCCESS ;
}
}
char * * sep_string ;
@ -472,6 +468,7 @@ int repl(State* state, FILE *input) {
@@ -472,6 +468,7 @@ int repl(State* state, FILE *input) {
split_string ( & sep_string , & num_words , line , ' ' ) ;
int err = check_pipes ( state , num_words , sep_string ) ;
if ( err = = ER_NOT_EXISTS ) {
expand_command ( state , num_words , sep_string ) ;
}
@ -517,8 +514,8 @@ int startup(State *state, int argc, char **argv) {
@@ -517,8 +514,8 @@ int startup(State *state, int argc, char **argv) {
perror ( " Config file error " ) ;
return err ;
}
fclose ( rc ) ;
}
fclose ( rc ) ;
if ( argc = = 2 ) {
FILE * script_text = fopen ( argv [ 1 ] , " r " ) ;