Skip to content

Commit

Permalink
fix moving the cursor back up on failure
Browse files Browse the repository at this point in the history
Fixes #9

When stdout is empty we were trying to move UP -1 lines, which
happens to work in some terminal emulators
but it turns out not in others, and is a silly thing to do anyway.
  • Loading branch information
codekitchen committed Feb 22, 2020
1 parent 284e447 commit 5f04a9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ int read_command(const char *command, size_t *count, size_t *shown, size_t *tota
waitpid(pid, &status, 0);
if (status != 0) {
// show the stderr instead
termput1("UP", (*shown) - 1);
*shown = *total = 0;
if ((*shown) > 0)
termput1("UP", *shown);
*count = *shown = *total = 0;
read_show_output(c_stderr, count, shown, total);
}
fclose(c_stderr);
Expand Down

0 comments on commit 5f04a9e

Please sign in to comment.