Browse Source

Print control sequences instead of executing /bin/clear

Change of strategy allows users to specify '-c' twice to erase the
scrollback buffer.
pull/68/head
Eric Radman 1 week ago
parent
commit
920689e965
4 changed files with 29 additions and 6 deletions
  1. +2
    -0
      NEWS
  2. +3
    -4
      entr.1
  3. +10
    -2
      entr.c
  4. +14
    -0
      entr_spec.c

+ 2
- 0
NEWS View File

@ -1,6 +1,8 @@
= Next Release: 4.8
- Set a maximum of 2^19 watches to guard against absurd file open limits
- Use control sequences to clear the display and specify '-c' twice to erase
the scrollback buffer
= Release History


+ 3
- 4
entr.1 View File

@ -13,7 +13,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd January 02, 2021
.Dd February 18, 2021
.Dt ENTR 1
.Os
.Sh NAME
@ -47,11 +47,10 @@ This option has no effect in conjunction with the
.Fl r
flag.
.It Fl c
Execute
.Pa /usr/bin/clear
before invoking the
Clear the screen before invoking the
.Ar utility
specified on the command line.
Specify twice to erase the scrollback buffer.
.It Fl d
Track the directories of regular files provided as input and exit if a new file
is added.


+ 10
- 2
entr.c View File

@ -372,7 +372,7 @@ set_options(char *argv[]) {
aggressive_opt = 1;
break;
case 'c':
clear_opt = 1;
clear_opt = clear_opt ? 2 : 1;
break;
case 'd':
dirwatch_opt = 1;
@ -461,8 +461,16 @@ run_utility(char *argv[]) {
err(1, "can't fork");
if (pid == 0) {
/* 2J - erase the entire display
* 3J - clear scrollback buffer
* H - set cursor position to the default
*/
if (clear_opt == 1)
system("/usr/bin/clear");
printf("\033[2J\033[H");
if (clear_opt == 2)
printf("\033[2J\033[3J\033[H");
fflush(stdout);
/* Set process group so subprocess can be signaled */
if (restart_opt == 1) {
setpgid(0, getpid());


+ 14
- 0
entr_spec.c View File

@ -797,6 +797,19 @@ int set_options_07() {
return 0;
}
/*
* Parse command line arguments with the clear scrollback option
*/
int set_options_08() {
int argv_offset;
char *argv[] = { "entr", "-cc", "echo", NULL };
argv_offset = set_options(argv);
ok(clear_opt == 2);
return 0;
}
/*
* In restart mode the first action should be to start the server
*/
@ -957,6 +970,7 @@ int test_main(int argc, char *argv[]) {
run(set_options_05);
run(set_options_06);
run(set_options_07);
run(set_options_08);
run(watch_fd_restart_01);
run(watch_fd_restart_02);
run(run_utility_01);


Loading…
Cancel
Save