<commit_before>#!/bin/bash

IGNORE_FILE=.reloadignore
IGNORE=""
SLEEP=1
SIGNAL="-SIGTERM"
#SIGNAL="-SIGINT"


function ctrlc() {
	if [ -n "$PID" ]
	then
		kill $SIGNAL $PID
	fi
	exit 0
}

trap ctrlc INT

if [ $# -eq 0 ]; then
	echo Specify command to run
	exit 1
fi

if [ -f $IGNORE_FILE ]; then
	IGNORE=`echo $(cat .reloadignore) | tr " " "|"`
fi

echo Watching current directory, ignored file pattern: $IGNORE

INOTIFY_OPTS="-r -q -e close_write"

if [ -n "$IGNORE" ]; then
	INOTIFY_OPTS="$INOTIFY_OPTS --exclude \"$IGNORE\""
fi

while true; do
  $@ &
  PID=$!
  inotifywait $INOTIFY_OPTS .
  disown $PID
  kill $SIGNAL $PID
  #sleep $SLEEP  #TODO: smart wait checking if process alive<commit_msg>fix shell command, but still doesn't work in subdirs<commit_after>#!/bin/bash

IGNORE_FILE=.reloadignore
IGNORE=""
SLEEP=0.5
SIGNAL="-SIGTERM"
#SIGNAL="-SIGINT"
EVENTS=modify

function ctrlc() {
	if [ -n "$PID" ]
	then
		kill $SIGNAL $PID
	fi
	exit 0
}

trap ctrlc INT

if [ $# -eq 0 ]; then
	echo Specify command to run
	exit 1
fi

if [ -f $IGNORE_FILE ]; then
	IGNORE=`echo $(cat .reloadignore) | tr " " "|"`
fi

echo Watching current directory, ignored file pattern: $IGNORE

INOTIFY_OPTS="-r -q -e $EVENTS"

if [ -n "$IGNORE" ]; then
	INOTIFY_OPTS="$INOTIFY_OPTS --exclude \"$IGNORE\""
fi

while true; do
  $@ &
  PID=$!
  inotifywait $INOTIFY_OPTS .
  disown $PID
  kill $SIGNAL $PID
  #sleep $SLEEP  #TODO: smart wait checking if process alive
  #TODO: loop with inotifywait
{'fraction_non_alphanumeric': 0.14131169709263017, 'fraction_numerical': 0.006085192697768763, 'mean_word_length': 3.6835443037974684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3243246', 'n_tokens_mistral': 645, 'n_tokens_neox': 600, 'n_words': 176}