summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2021-10-24 01:45:15 -0400
committerRobby Zambito <contact@robbyzambito.me>2021-10-24 01:45:15 -0400
commit98181b833eb4dc6440b73205e64ac010cc4b364c (patch)
treeb8bca1f5177cb09094d098b48ec0a4212de38146
parent8d2460e9f61d63dd14ee95784b6f5d1fd1219395 (diff)
Commands run and print to stdout
-rw-r--r--rvsh.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/rvsh.c b/rvsh.c
index db2ddd5..211f3a0 100644
--- a/rvsh.c
+++ b/rvsh.c
@@ -127,6 +127,8 @@ void run_reverse_command(char *command) {
pid_t bash_pid;
union pipe bash_input, bash_output;
FILE *bash_input_f, *bash_output_f;
+ char *line;
+ size_t line_capacity;
pipe(bash_input.filedes);
pipe(bash_output.filedes);
@@ -153,7 +155,14 @@ void run_reverse_command(char *command) {
bash_input_f = fdopen(bash_input.write_end, "w");
bash_output_f = fdopen(bash_output.read_end, "r");
- put_stream_rev(bash_output_f);
+ line = NULL;
+ line_capacity = 0;
+ while (getline(&line, &line_capacity, bash_output_f) > 0) {
+ strrev(line);
+ printf("%s", line);
+ }
+
+ free(line);
fclose(bash_input_f);
fclose(bash_output_f);
@@ -168,7 +177,6 @@ int main(void) {
add_history(line);
strrev(line);
- /*puts(line);*/
run_reverse_command(line);