Giter VIP home page Giter VIP logo

entr's Introduction

Event Notify Test Runner

A utility for running arbitrary commands when files change. Uses kqueue(2) or inotify(7) to avoid polling. entr was written to facilitate rapid feedback on the command line.

Source Installation - BSD, Mac OS, and Linux

./configure
make test
make install

To see available build options run ./configure -h

Docker and WSL

Incomplete inotify support on Windows Subsystem for Linux and Docker for Mac may cause entr to respond incorrectly. Setting the environment variable ENTR_INOTIFY_WORKAROUND enables entr to operate in these environments.

Linux Features

Symlinks can be monitored for changes by setting the environment variable ENTR_INOTIFY_SYMLINK.

Man Page Examples

Rebuild a project if source files change, limiting output to the first 20 lines:

$ find src/ | entr -s 'make | head -n 20'

Launch and auto-reload a node.js server:

$ ls *.js | entr -r node app.js

Clear the screen and run a query after the SQL script is updated:

$ echo my.sql | entr -cp psql -f /_

Rebuild project if a source file is modified or added to the src/ directory:

$ while sleep 0.1; do ls src/*.rb | entr -d make; done

Auto-reload a web server, or terminate if the server exits

$ ls * | entr -rz ./httpd

News

Notification of new releases are provided by an Atom feed, and release history is covered in the NEWS file.

entr's People

Contributors

apeschar avatar arkamar avatar eradman avatar funollet avatar iamleot avatar kconner avatar lubomir avatar matti avatar n-r-k avatar ottok avatar pylipp avatar rx14 avatar stevenhollett avatar szlend avatar tartley avatar xakon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entr's Issues

Force kill process on file change?

I'm using the following command
ls *.zip | entr ./restart.sh

Restart.sh

#/bin/bash
pkill -f "update-server"
rm -rf cache
rm -rf update-server
unzip ./update-server.zip
./update-server

This script kills a process, unzips a folder and restarts it. The problem is this process is a server which stays alive forever. Is there any option to make entr force kill this process when changes are detected? Thanks.

clear option without blinking

I'm not sure if it's even possible but I'm just thinking out-loud for now.

Would it be possible to for entr to redraw the result of command with out blinking when using option -c?

(btw, entr is pretty cool 👍)

Ability to return utility exit code with oneshot option?

I use entr in some extended functionality of the product I work on, and recently a user raised tilt-dev/tilt-extensions#92 -- they're running into trouble b/c they're using entr as part of a Kubernetes job, and Kubernetes needs to know the exit code of the utility to declare that the job succeeded or failed.

Current behavior (from #29):

The new -z option will return 0 if the utility was executed, or 1 if execution failed (permissions, non-existent path, etc.)

Any chance of the oneshot option returning the exit code of the utility (either by default, or when a specific flag is set)?

My first instinct would be to change this line to exit(WEXITSTATUS(status)) -- though there's no way to distinguish status code 1 meaning "entr failed to run your utility" and "utility ran and exited with status code 1".

[Just brainstorming, feel free to ignore] Assuming that's an important distinction to preserve, one solution might be to designate a specific exit code to mean "entr encountered an error" and assume that any other code is a return code from the utility. Though this framework only makes sense with the "one-shot" option, and it would be weird in other cases to have entr failures return status code 77 (or whatever). Maybe a specific flag (say, -Z) for "run entr as a one-shot and return back the status code of the utility (or 77 for entr failure)"?

Hint for testing if inotify is fully supported?

In the README we are warned about "Incomplete inotify support on WSL and Docker for Mac can cause entr to respond inconsistently", may I ask if there is a way to check/test if the current environment has complete inotify support? e.g. an alpine docker container running on an Ubuntu host machine?

Unable to stat?

When I do
ls notes/ | entr make generat

it produces this error
entr: unable to stat 'file.md'

Any workarounds?

Watch a specific directory.

I'm wanting to monitor for a file change two directories deep, where the filename is known but the middle directory is not. This is what I have so far:

while true;
    do ls foo/*/bar.txt | entr -dp echo /_;
done

If when I start the while loop the file foo/1/bar.txt exists, it seems like the directory foo/1 is detected to be watched, not foo (which makes total sense, it's just not what I'm trying to do).

I can see in the documentation there is a reference to -d being able to used with an explicitly supplied directory, but try as I might I can't get the syntax to work. I'm not sure if what I'm trying to achieve is not currently supported, or if it is and I'm just missing something from a syntax perspective.

Could you offer some clarification?

execute utility only once

is there a way to use entr to simply block execution of a script until a file has changed? right now i'm using this polling strategy, but would prefer an interrupt:

while <file-has-not-changed> ; do sleep 1 ; done

i was hoping that ls foo | entr -pn true or similar might work, but entr doesn't exit. is there a work around? if not, how easy would it be to add a new flag to entr?

thanks for the great utility!

entr process dies when a watched file is deleted (repost)

This was originally asked by @basti1302 in 2016 : clibs/entr#4 (comment)

It was apparently forwarded to the bit bucket tracker, but the issue is now a 404: https://bitbucket.org/eradman/entr/issues/40/entr-process-stops-when-a-watched-file-is

I'm posting this since it's been a couple years and I want to be sure Google has some decisive answers for users that encounter this (Hopefully!)

Here is the example verbatim, that still happens with entr 4.4:

> touch a
> touch b
> touch c
> ls a b c  | entr echo Yo

Now, in another shell, each touch a, touch b or touch c will produce a Yo, as expected, but a rm a will cause the entr process to stop with the following error message:

> rm b
entr: cannot open `b': No such file or directory

Does entr(1) have a way to handle cleaned / removed / unlinked files? Is there a workaround?

(Thank you very much for this application!)

Doc suggestion: parallel entr pipelines

This is a documentation suggestion for running multiple tasks as individual pipelines outputting logs to the same terminal window with make. For example in a scenario where you want to transpile typescript, and optimize css in separate execution commands.

make -j
SHELL := /bin/bash

entr: entr-ts entr-css

entr-ts:
  @while true; do find ./pkg -name '*.ts' -d | entr -d make ts; done

entr-css:
  @while true; do find ./pkg -name '*.css' -d | entr -d make css; done

ts:
  # transpile typescript

css:
  # optimize css

I've tried, or used a handful of "file-watching task-runners", and in practice entr stands out for it's simplicity & reliability. It just works, and well. kudos to the maintainers!

docker for mac patch getting old

The patch file version is http://eradman.com/entrproject/patches/entr-3.9-docker while the entr is at 4.x

Currently it does apply and the binary seems to work, see https://github.com/matti/docker-entr/blob/master/build/ubuntu/Dockerfile#L13-L17

Also, could it be possible to include the patch in entr and have the behaviour available as an option? I think I've wasted something like an 2 hours trying to figure out what was wrong with docker-for-mac and entr - just found out #3 by accident

Doc suggestion: comparison w/ similar tools

Hi.

I just stumbled upon your project which seems nicely put.

I have a very simple suggestion.

I guess quite a few people are more familiar w/ the venerable incrond(8) (Linux) and filewatcherd(8) (FreeBSD) for this kind of functionality.

A quick section for X-linking similar projects w/ a brief rundown of differences could be beneficial in choosing the right tool for the right job.

As I understand it:

  • entr is more for on-demand command launch, taking list of files to watch as a piped input while others rely on their own crontab-like configuration
  • by this on-demand approach, entr is more suitable for interactive development (e.g. CI test) while others are more for backend automation applications (e.g. provisioning)
  • entr is more cross-platform (even though incrond appears to have been ported to BSD)

But this interpretation might be wrong, hence the benefit of having a more explicit comparison.

entr can't be stopped

Just doing a simple test

while true; do ls test* | entr -d echo changed: /_; done

while in the directory ~/util on Ubuntu 18.04.

I did some testing to test if it picks up changes from new files i added with a name starting with "test". Then I added some directories using mkdir -p and saw that it did not watch files inside there (all what I expected)

The behavior is that when I press Ctrl+C it just prints changed: /home/slu/util/testfile and carries on merrily. First few times it did this spamming Ctrl+C worked fine. But now, for some reason, no amount of SIGINT will stop it, and neither does SIGKILL from htop stop it. pkill -9 -f entr isn't working either.

Version 4.4, built from source.

I'll need to kill the shell parent process to stop it. I was really hoping to finally find a robust inotify tool. Linux is so good at everything except monitoring its filesystem.

New release from master ?

Latest release is v4.3 from September 2019 (last year!)

There are good commits waiting in master, especially the Docker for Mac workaround e158c36

How about releasing v4.4 from the current state of master? Thank you !

Entr does not restart given command on crash

In this case, I'm using entr to restart a Ruby process when source files change.

Problem: entr does not restart the process when the Ruby process crashes (it's a development environment after all).

My environment is minikube in MacOS. Live reloading works using the entr inode workaround.

Is the problem in my configuration or what could cause this?

2020-02-18 at 11 52

Entrypoint:

#! /usr/bin/env bash

set -euo pipefail

_term() {
 >&2 echo "TERM"
 exit 0
}

trap "_term" TERM

OPERATOR="${1:-}"
COMMAND="bin/operators/${OPERATOR}"

if [[ -z "${OPERATOR}" ]]; then
  echo "Error: Missing parameter operator name."
  echo "Usage: $0 operator_name"
  exit 1
elif [[ ! -x "${COMMAND}" ]]; then
  echo "Error: Command '${COMMAND}' is not executable."
  exit 1
fi

if [[ "${ENV}" = "development" ]]; then
  export ENTR_INOTIFY_WORKAROUND="yespls"
  (
    while true; do
      set +e
        find . | entr -rd "${COMMAND}"
      set -e
    done
  ) &
else
  set +e
    "${COMMAND}" &
  set -e
fi

wait $!

use aliases command in entr

Hi
I have an alias set like
alias my_cmd='./do_something && ./do_something_else && echo "done"'

how can I use it with entr like

git ls-files | entr my_cmd

??

"entr.c", line 24.10: 1506-296 (S) #include file <err.h> not found.

I'm not able to build entr on AIX.
The make ends in error:

cc -DRELEASE="4.6" entr.c -o entr
"entr.c", line 21.10: 1506-296 (S) #include file <sys/event.h> not found.
"entr.c", line 24.10: 1506-296 (S) #include file <err.h> not found.
"entr.c", line 114.16: 1506-007 (S) "struct kevent" is undefined.
"entr.c", line 121.19: 1506-045 (S) Undeclared identifier kevent.
"entr.c", line 129.18: 1506-045 (S) Undeclared identifier warnx.
"entr.c", line 130.17: 1506-045 (S) Undeclared identifier errx.
"entr.c", line 207.46: 1506-045 (S) Undeclared identifier EVFILT_READ.
"entr.c", line 207.59: 1506-045 (S) Undeclared identifier EV_ADD.
"entr.c", line 207.67: 1506-045 (S) Undeclared identifier NOTE_LOWAT.
"entr.c", line 486.16: 1506-007 (S) "struct kevent" is undefined.
"entr.c", line 506.48: 1506-045 (S) Undeclared identifier EV_ADD.
"entr.c", line 506.57: 1506-045 (S) Undeclared identifier EV_CLEAR.
"entr.c", line 506.67: 1506-045 (S) Undeclared identifier NOTE_DELETE.
"entr.c", line 506.67: 1506-045 (S) Undeclared identifier NOTE_WRITE.
"entr.c", line 506.67: 1506-045 (S) Undeclared identifier NOTE_RENAME.
"entr.c", line 506.67: 1506-045 (S) Undeclared identifier NOTE_ATTRIB.
"entr.c", line 506.34: 1506-045 (S) Undeclared identifier EVFILT_VNODE.
"entr.c", line 550.16: 1506-007 (S) "struct kevent" is undefined.
"entr.c", line 551.23: 1506-194 (S) Incomplete type is not allowed.
"entr.c", line 595.64: 1506-045 (S) Undeclared identifier EVFILT_READ.
"entr.c", line 598.37: 1506-045 (S) Undeclared identifier EV_DELETE.
"entr.c", line 598.48: 1506-045 (S) Undeclared identifier NOTE_LOWAT.
"entr.c", line 609.41: 1506-045 (S) Undeclared identifier EVFILT_VNODE.
"entr.c", line 624.40: 1506-045 (S) Undeclared identifier NOTE_DELETE.
"entr.c", line 625.40: 1506-045 (S) Undeclared identifier NOTE_RENAME.
"entr.c", line 627.29: 1506-045 (S) Undeclared identifier NOTE_WRITE.
"entr.c", line 627.29: 1506-045 (S) Undeclared identifier NOTE_ATTRIB.
make: *** [Makefile:29: entr] Error 1

Then I expanded -> CPPFLAGS += -DRELEASE="${RELEASE}" -I missing

and make ends in error:
"entr.c", line 24.10: 1506-296 (S) #include file <err.h> not found.
"entr.c", line 129.18: 1506-045 (S) Undeclared identifier warnx.
"entr.c", line 130.17: 1506-045 (S) Undeclared identifier errx.
make: *** [Makefile:29: entr] Error 1

I am on AIX 7.2 and gcc version 8.3.0 (GCC).

Does not work with "hardware" files

I want to run print out my laptop's battery percentage whenever it changes.
I tried running echo "/sys/class/power_supply/BAT0/capacity" | entr cat /_" but it only
executes once.
Why is that?
Thanks!

`touch`ing a watched file doesn't trigger execution

Given invocation echo '.restart' | /entr -rz util.sh, I see:

  1. echo foo >> .restart (i.e. appending to the file) triggers the utility (as expected)
  2. echo foo > .restart multiple times in a row (i.e. overwriting the file with the same contents as it had before) triggers the utility(as expected)
  3. touch .restart does NOT trigger util.sh, even though the timestamp on the file is updated.

Case 3 is surprising to me: is it expected that touching a watched file doesn't trigger the utility? If so, what's the logic here?

not triggering when window isnt focussed

I have a very obscure problem. Entr is not triggering anything, until I focus the window!

I couldn't imagine why or how this is happening, so did an strace:

poll([{fd=3, events=POLLIN}], 1, -1

(waiting for change...)

(i actually made a change, but nothing happens, until I focus the terminal window, then it returns from the syscall)

)    = 1 ([{fd=3, revents=POLLIN}])
read(3, "\7\0\0\0\10\0\0\0\0\0\0\0\0\0\0\0", 1024) = 16
poll([{fd=3, events=POLLIN}], 1, 50)    = 0 (Timeout)
kill(-79149, SIGTERM)                   = 0
wait4(79149, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGTERM}], 0, NULL) = 79149
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=79149, si_uid=1000, si_status=SIGTERM, si_utime=0, si_stime=0} ---
brk(0x5612035da000)                     = 0x5612035da000
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f31b9dcda10) = 79353
poll([{fd=3, events=POLLIN}], 1, 1)     = 0 (Timeout)
poll([{fd=3, events=POLLIN}], 1, 50)    = 0 (Timeout)
poll([{fd=3, events=POLLIN}], 1, -1

(waiting for next change..)

Using i3wm on a ZFS filesystem on ubuntu 20.

Tried with gnome terminal and xterm. (will try on a text console without x as well)

support NUL-separated input

It would be nice if entr accepted filenames containing newlines. Then, I could safely pass a list of files to entr separated by NULs: zsh> print -Nnr - src/* | entr .... Perhaps this could be toggled with the addition of a -0 flag?

Feature request: pass watched files as command line arg/flag (NOT via pipe)

(Unless of course this feature already exists, in which case, great!)

I'd like to be able to use entr on Docker images without bash/sh, which means that piping won't be available to me; ideally I would be able to specify files to watch as an arg, e.g.

["entr", "--files=a.txt,b.txt,c.txt", "-rz", "my_util.sh"]

(A smaller point in favor of this feature is that while piping makes perfect sense for a call like ls | entr ..., if i just want to watch a single file, it looks a little silly to say echo one-file.txt | entr ...)

entr -d inhibited by rm

Hello,

I'm trying to replace the use of inotifywait by entr in order to be more portable and I noticed a problem:

user@gentoo-zen2700x> touch 1
user@gentoo-zen2700x> echo . | entr -pdn echo HELLO &
[1] 13297 13298
user@gentoo-zen2700x> rm 1
user@gentoo-zen2700x> touch 2
user@gentoo-zen2700x> touch 3
user@gentoo-zen2700x> HELLO                                                                                                             ~/Programming/mus
entr: directory altered

[1]  + done       echo . |
       exit 2     entr -pdn echo HELLO

As you can see, entr doesn't react to touch 2 for some reason. Also, for some reason, entr feels a lot slower than inotifywait -e CREATE to react. Any reason for that?

Tested with entr-4.2 on Gentoo amd64.

Limit 1024 on Linux tells that `entr` is not using inotify

I try to set a build watcher for tflint and get hit by 1024 limit.

$ fd "\.go$" | entr go build -o ./flt
entr: Too many files listed; the hard limit for your login class is 1024. Please consult
http://eradman.com/entrproject/limits.html

But my limit is 8192.

$ cat /proc/sys/fs/inotify/max_user_watches  
8192

entr does not use inotify. Why?

entr does not stop when the terminal is closed

Hello!

When I run entr, for example using this command:

$ touch /tmp/ab
$ echo /tmp/ab | entr -n -r -s "echo New; sleep 123456789"

I can check in another terminal that the command is running:

$ ps aux | grep 123456789
me        445  0.0  0.0   6428   996 pts/4    S+   12:51   0:00 entr -n -r -s echo New; sleep 123456789
me        446  0.0  0.0 219012  2560 pts/4    S    12:51   0:00 /nix/store/xadrr3l5jvkkm3g3lb2g81j5wz51zqdv-bash-interactive-4.4-p23/bin/bash -c echo New; sleep 123456789 /tmp/ab
me        447  0.0  0.0 218776   320 pts/4    S    12:51   0:00 sleep 123456789

If I type Ctrl-C, the processes spawn by entr are killed, which is great. I can see it by running again:

$ ps aux | grep 123456789

However, if I close my terminal (konsole in my case), the process is not killed:

$ ps aux | grep 123456789
me        446  0.0  0.0 219012  2560 ?        S    12:51   0:00 /nix/store/xadrr3l5jvkkm3g3lb2g81j5wz51zqdv-bash-interactive-4.4-p23/bin/bash -c echo New; sleep 123456789 /tmp/ab
me        447  0.0  0.0 218776   320 ?        S    12:51   0:00 sleep 123456789

You can see that it is not attached to any pseudo terminal, and if you check which are the ancestors of entr, you will see that it's systemd process with pid 1.

Is this a feature or a bug? If it's a feature, is it possible to disable it? Indeed, I use entr to update a server, and sometimes the terminal get closed, usually when I open the terminal from emacs and restart emacs to update my configuration. And then, I cannot restart my server (port already in use) without killing all the spawn processes, which is quite annoying.

entr usage in systemd services

To me it is unclear how to properly use entr in cases of init scripts (or rather systemd services). I find my service hanging on systemctr stop, with entr being the process that is waited on. After some time, when the timeout comes, systemd cleans up and kills the remaing processes. But it keeps me from rapidly restarting the service when i need to.

This snipplet shows how I use entr currently, in the bash script started as a service by systemd. "queue" is a fifo.

#job producer

while true;
do
  # check for any model files in SimIn
  shopt -s nullglob dotglob
  models=(*.mph)
  shopt -u nullglob dotglob
  for i in "${models[@]}"
  do
    echo "${i}" > "${tmpdir}"/queue
  done

  #waiting for the next model to be added to the directory 
  find . | entr -dpnr echo "directory changed"

done
echo "quit" > "${tmpdir}"/queue

wait "${runner_pid}"

how do i do it properly?

Python Breakpoints

Thank you for creating this, it is an awesome very neat program.

I'd like to be able to use the program while debugging python code so that when a file changes, the process that is running (PDB) exits and restarts the entire python program.

You mention this issue at the end of the documentation https://eradman.com/entrproject/ but I was wondering if there was a way of getting this to work?

  File "/home/harry/miniconda3/envs/audiomentations/lib/python3.8/cmd.py", line 126, in cmdloop
    line = input(self.prompt)
RuntimeError: input(): lost sys.stdin

Feature Request: execute given command only on regexp match

Hi,

in modern tests frameworks like rspec, phpunit, codeception, django, whatever it is common to have the application code separated from the test code. We basically have this structure:

app/ <-- application code
tests/ <-- test code

When i want to automate the test execution during the save of an file, i need to watch both the test and the application file. I only want to run the tests file though.

So doing a

ls **/*.php | entr vendor/bin/codecept run unit /_

would try to execute also the application code instead of only the test code.

My Question: is there already a solution to this Problem ? If not,
My Proposal: add an option to match the absolute path of the changed file to a regexp.

Example:

entr --only-execute-on-match /tests/

This would mean that entr only executes the given command when the absolute path matches the given regular expression and this would solve the problem:

ls **/*.php | entr --only-execute-on-match /tests\/ vendor/bin/codecept run unit /_

Watching two files with entr like:

app/DispatchOrder.php
tests/DispatchOrderTest.php

would only execute the DispatchOrderTest.php file on the change of any file because the regexp "tests/" needs to match.

what are your ideas about this?

Use entr to automate "source .bashrc"

I try to use:
ls ~/.bashrc | entr -p source ~/.bashrc
But I get an error:
entr: exec source: No such file or directory

What would be the correct way to automate sourcing .bashrc?

Is it possible to use `-r` with an interactive task?

I'd like to use entr to run a command that is interactive. If I don't say 'yes' to the command though, it holds the terminal and so it doesn't re-run unless I interact with that pane. It would be nice to be able to have entr kill the command on updates but still allow me to say 'yes' when I'm ready to let the command apply changes.

Entr: trying to trigger function while monitoring file change

I'm trying to monitor some files with entr:

do_it(){ echo Eita!; }
while true; do ls folder/* more-folder/* | entr -pd do_it; done
>> entr: exec do_it: No such file or directory

However, this works:

while true; do ls folder1/* folder2/* | entr -pd echo Eita!; done

What am I doing wrong?

I am trying to use entr to help me with epub editing. So I this function will trigger an update command to a epub viwer as well as refresh a window in a web browser. (I'd love to see more real examples that would help me doing it...)

entr fails with regular user

This probably isn't a problem with entr but a problem with linux administration. Any help would be appreciated.
I recently switched to fedora for my desktop, and now entr isn't working for me.
user watches:

~/D/entr (master|✔) $ cat /proc/sys/fs/inotify/max_user_watches
8192

example run:
~/D/entr (master|✔) $ ls | entr -s "echo 'hi'"
entr: Unable to allocate memory for kernel queue. Please consult http://eradman.com/entrproject/limits.html

However when run as root
~/D/entr (master|✔) [1] $ ls | sudo entr -s "echo 'hi'"
hi
bash returned exit code 0

I would rather not run all my development tests as root. Any ideas how to get it to work as a regular user?

Segmentation fault on MacBook M1 due to unlimited file descriptors

I get segmentation faults with the latest version of entr (4.7 or git checkout).
This happens on a MacBook M1 (Arm chip), running macOS Big Sur, not much changed from the default configuration.

Backtrace:

(lldb) process launch -i input.txt  -- -s 'make'
Process 36108 launched: '/Users/jer/code/entr/entr' (arm64)
cur: 9223372036854775807
max: 9223372036854775807
Process 36108 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001000023d8 entr`process_input(file=0x00000001f9273240, files=0x0000000000000000, max_files=9223372036854775807) at entr.c:305:19
   302 				continue;
   303 			}
   304 			if (S_ISREG(sb.st_mode) != 0) {
-> 305 				files[n_files] = malloc(sizeof(WatchFile));
   306 				strlcpy(files[n_files]->fn, buf, MEMBER_SIZE(WatchFile, fn));
   307 				files[n_files]->is_dir = 0;
   308 				files[n_files]->file_count = 0;

I added some logging:

n_files here is 0. max_files is -1.

After getrlimit(RLIMIT_NOFILE) I get:

rl.rlim_cur = 9223372036854775807
rl.rlim_max = 9223372036854775807

that.
That's UINT64_MAX That's INT64_MAX. sysconf(_SC_OPEN_MAX) also returns that.

As rlim_cur is the minimum out of all of that it's INT64_MAX before being passed to process_input. Now process_input takes an int, so it's coerced and becomes -1.

Seems my file descriptors are unlimited by default:

$ ulimit -n
unlimited

Changing it to some more reasonable low number makes entr work as expected:

$ ulimit -n 1024
$

Question:

  • Should entr enforce a more reasonable limit for this case?
  • Should process_file maybe not use a different integer type than the one passed in?

entr -a not behaving as I'd expect

I'm not sure this is a problem on entr's end, but:
$ touch watchme; ls watchme | entr -a echo changed
$ echo "asdf" >> watchme; echo "asdf" >> watchme; echo "asdf" >> watchme;
results in 1-2 invocations of echo changed as opposed to the expected three.

I discovered this while trying to use entr as a last resort for running one command per line written to a log file (was having issues with pipe buffers and finally got it sorted using stdbuf).

Is it possible the shell is buffering the writes?

Goes and tries stdbuf -o0 echo asdf >> watchme; x3...

Sure enough! Will submit and close just in case anyone else...

Please add a shortcut for passing stdin from a file

I often find myself using entr to write helper scripts that work on files. I would love it if I could write those scripts to read from stdin and write to stdout, but there isn't a really easy way to do that with entr since it would receive shell redirection if it was done as an argument to the cli itself. It would be nice if there were a built in entr flag to tell it to send stdin to a command from a specific file to make this use case easier.

suspended problem

I use entr in terminal or vim, want to exit entr when close vim or terminal

ls * | entr reload-browser chrome &> /dev/null &

if I run this command in terminal

[1]  + 123095 done                    ls --color=tty * |
       123096 suspended (tty output)  entr reload-browser chrome &> /dev/null

refresh one time and then doesn't work

if I run this command in vim:

:! ls * | entr reload-browser chrome &> /dev/null &

always work, even I exit vim

can I Run the program in the background and exit when vim or terminal exit?

I can't get get the version og `entr`

Hello!

I tried get the version of entr, but I can't.
My script:

f_test_entr_version(){
  local version
  version="$(entr - | cut -d ' ' -f 2 | head -n 1)"
  f_compare_version "$G_ENTR_VERSION" "$version"
  return $?
}

What I am doing wrong?

A suggestion: add a -h and/or -v option to output help or/and version.

What's "entr" meaning?

The name is too hard to remember, I have to search the command when I need it every time.

Notification for successful save?

Maybe i am stupid and there is a way, it would nice to have some kind of notification, when save is made i.e. when doing some coding and getting errors in terminal, it is hard to tell that the code is correct when saving because you not always looking at terminal when saving and one have to cancel entr and run again to make sure there are no errors.

Known issues w/ docker-for-mac?

entr is able to detect filechanges locally on the host, but not within the docker container. I'm using a mounted volume for the source files, and can see that find . is passing files to entr, which successfully runs make once, but no file changes are detected.

25 of 25 tests pass when installing entr, but there is output mentioning something missing:

Step 6/26 : RUN cd ./entr && ./configure && make test && make install
 ---> Running in 0055d55f74d0
cc  -D_GNU_SOURCE -D_LINUX_PORT -Imissing -DRELEASE=\"4.3\" missing/strlcpy.c missing/kqueue_inotify.c entr_spec.c -o entr_spec
cc  -D_GNU_SOURCE -D_LINUX_PORT -Imissing -DRELEASE=\"4.3\" missing/strlcpy.c missing/kqueue_inotify.c entr.c -o entr
Running unit tests
25 of 25 tests PASSED
install entr /usr/local/bin
install -m 644 entr.1 /usr/local/share/man/man1

I've tried both of the following commands.

find -d ./src | entr -d make
ls -d ./src/**/* | entr -d make

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.