Skip to content

Instantly share code, notes, and snippets.

@t-mw
Created January 8, 2020 21:18
Show Gist options
  • Save t-mw/8614b805e464f3dd73d888988e0025fb to your computer and use it in GitHub Desktop.
Save t-mw/8614b805e464f3dd73d888988e0025fb to your computer and use it in GitHub Desktop.
#!/bin/bash
# see https://github.com/porglezomp-misc/live-reloading-rs/issues/1
set -e
name="libreloadable"
extension="so"
dir="./target/debug"
path="${dir}/${name}.${extension}"
cleanup() {
rm -f "${dir}/${name}_"*;
}
trap cleanup EXIT
timestamp() {
date +"%s";
}
run() {
name2="${name}_$(timestamp)";
for f in "$dir/$name".*; do cp -r "$f" "${f/$name/$name2}"; done
}
export name
export extension
export dir
export path
export -f timestamp
export -f run
inotifywait --include "$name\.$extension" -m -e CREATE "$dir" | xargs -n1 sh -c '$(run);'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment