Codebase list entr / 007b6ec
Update upstream source from tag 'upstream/4.8' Update to upstream version '4.8' with Debian dir 94c6b0581f7c1f167b518e9ed6e76e348d612667 Yuri D'Elia 3 years ago
5 changed file(s) with 49 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
00 PREFIX ?= /usr/local
11 MANPREFIX ?= ${PREFIX}/man
2 RELEASE = 4.7
2 RELEASE = 4.8
33 CPPFLAGS += -DRELEASE=\"${RELEASE}\"
44
55 all: versioncheck entr
00 = Release History
1
2 == 4.8: February 26, 2021
3
4 - Set a maximum of 2^19 watches to guard against absurd file open limits on
5 MacOS
6 - Use control sequences to clear the display and specify '-c' twice to erase
7 the scrollback buffer
18
29 == 4.7: January 29, 2021
310
1212 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414 .\"
15 .Dd January 02, 2021
15 .Dd February 18, 2021
1616 .Dt ENTR 1
1717 .Os
1818 .Sh NAME
4646 .Fl r
4747 flag.
4848 .It Fl c
49 Execute
50 .Pa /usr/bin/clear
51 before invoking the
49 Clear the screen before invoking the
5250 .Ar utility
5351 specified on the command line.
52 Specify twice to erase the scrollback buffer.
5453 .It Fl d
5554 Track the directories of regular files provided as input and exit if a new file
5655 is added.
113113 int n_files;
114114 int i;
115115 struct kevent evSet;
116 long open_max;
116117
117118 if ((*test_runner_main))
118119 return(test_runner_main(argc, argv));
163164 max_watches = (rlim_t)fs_sysctl(INOTIFY_MAX_USER_WATCHES);
164165 if(max_watches > 0) {
165166 rl.rlim_cur = max_watches;
167 open_max = max_watches;
166168 goto rlim_set;
167169 }
168170 #endif
169171 /* raise soft limit */
170 rl.rlim_cur = min((rlim_t)sysconf(_SC_OPEN_MAX), rl.rlim_max);
172 open_max = min(sysconf(_SC_OPEN_MAX), (long)rl.rlim_max);
173 if (open_max == -1)
174 err(1, "_SC_OPEN_MAX");
175
176 open_max = min(524288, open_max); /* guard against unrealistic replies */
177
178 rl.rlim_cur = (rlim_t)open_max;
171179 if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
172 err(1, "setrlimit cannot set rlim_cur to %d", (int)rl.rlim_cur);
180 err(1, "setrlimit cannot set rlim_cur to %ld", open_max);
173181
174182 rlim_set:
175183
180188 setenv("SHELL", "/bin/sh", 0);
181189
182190 /* sequential scan may depend on a 0 at the end */
183 files = calloc(rl.rlim_cur+1, sizeof(WatchFile *));
191 files = calloc(open_max+1, sizeof(WatchFile *));
184192
185193 if ((kq = kqueue()) == -1)
186194 err(1, "cannot create kqueue");
190198 usage();
191199
192200 /* read input and populate watch list, skipping non-regular files */
193 n_files = process_input(stdin, files, rl.rlim_cur);
201 n_files = process_input(stdin, files, open_max);
194202 if (n_files == 0)
195203 errx(1, "No regular files to watch");
196204 if (n_files == -1)
197205 errx(1, "Too many files listed; the hard limit for your login"
198 " class is %d. Please consult"
199 " http://eradman.com/entrproject/limits.html", (int)rl.rlim_cur);
206 " class is %ld. Please consult"
207 " http://eradman.com/entrproject/limits.html", open_max);
200208 for (i=0; i<n_files; i++)
201209 watch_file(kq, files[i]);
202210
364372 aggressive_opt = 1;
365373 break;
366374 case 'c':
367 clear_opt = 1;
375 clear_opt = clear_opt ? 2 : 1;
368376 break;
369377 case 'd':
370378 dirwatch_opt = 1;
453461 err(1, "can't fork");
454462
455463 if (pid == 0) {
464 /* 2J - erase the entire display
465 * 3J - clear scrollback buffer
466 * H - set cursor position to the default
467 */
456468 if (clear_opt == 1)
457 system("/usr/bin/clear");
469 printf("\033[2J\033[H");
470 if (clear_opt == 2)
471 printf("\033[2J\033[3J\033[H");
472 fflush(stdout);
473
458474 /* Set process group so subprocess can be signaled */
459475 if (restart_opt == 1) {
460476 setpgid(0, getpid());
797797 }
798798
799799 /*
800 * Parse command line arguments with the clear scrollback option
801 */
802 int set_options_08() {
803 int argv_offset;
804 char *argv[] = { "entr", "-cc", "echo", NULL };
805
806 argv_offset = set_options(argv);
807
808 ok(clear_opt == 2);
809 return 0;
810 }
811
812 /*
800813 * In restart mode the first action should be to start the server
801814 */
802815 int watch_fd_restart_01() {
956969 run(set_options_05);
957970 run(set_options_06);
958971 run(set_options_07);
972 run(set_options_08);
959973 run(watch_fd_restart_01);
960974 run(watch_fd_restart_02);
961975 run(run_utility_01);