Skip to content

Instantly share code, notes, and snippets.

@thewrongjames
Last active March 9, 2021 01:23
Show Gist options
  • Save thewrongjames/011111f26442606876b3d9fab03af5f0 to your computer and use it in GitHub Desktop.
Save thewrongjames/011111f26442606876b3d9fab03af5f0 to your computer and use it in GitHub Desktop.
Run make when any files passed as arguments are modified.
#!/bin/bash
description="Run make when any files passed as arguments are modified."
usage="Usage: makeonfilechange [files]"
if [ $# = 0 ]; then
echo $description
echo $usage
exit 1
fi
# Separate if statement becuase if $# = 0 then $1 evaluates to nothing and the
# test command errors because it gets an invalid number of arguments.
if [ $1 = --help -o $1 = -h ]; then
echo $description
echo $usage
exit 1
fi
while inotifywait -e modify $@; do
make
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment