Skip to content

Instantly share code, notes, and snippets.

@whardier
Created December 2, 2013 21:57
Show Gist options
  • Save whardier/7759833 to your computer and use it in GitHub Desktop.
Save whardier/7759833 to your computer and use it in GitHub Desktop.
set -e and trap to the rescue
#! /bin/bash
set -e
LOCKFILE="/tmp/things.lock"
trap "rm -f $LOCKFILE" EXIT
if [ -e "$LOCKFILE" ]; then
echo >&2 "Warning: $LOCKFILE present, not doing things."
exit 1
else
touch "$LOCKFILE"
fi
/usr/local/bin/things
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment