aboutsummaryrefslogtreecommitdiff
path: root/bin/grc
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-09 17:15:40 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-09 17:20:10 +1200
commit9fb350dc7c8cc5259ef24e0cb097031179fab1d6 (patch)
tree839dd0b8ee3f5323b1cd6aefa22b605b99437d62 /bin/grc
parentMention nosls/sls flags in slsf(1) man page (diff)
downloaddotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.tar.gz
dotfiles-9fb350dc7c8cc5259ef24e0cb097031179fab1d6.zip
Improve commenting/exit handling in binscripts
Diffstat (limited to 'bin/grc')
-rwxr-xr-xbin/grc10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/grc b/bin/grc
index 9a02d9da..0db91afa 100755
--- a/bin/grc
+++ b/bin/grc
@@ -1,10 +1,16 @@
#!/bin/sh
-# Argument or current dir is a Git repository with uncommitted changes
+# Check whether a directory is a Git repository with uncommitted changes
+
+# Enter given directory or bail
cd -- "${1:-.}" || exit
+
+# If not a Git repository at all, warn explicitly
if ! isgr ; then
printf >&2 'grc: Not a Git repository\n'
exit 1
fi
-isgr || exit
+
+# Exit 0 if the first command gives any output (added files) or the second one
+# exits 1 (inverted; differences in tracked files)
[ -n "$(git ls-files --others --exclude-standard)" ] ||
! git diff-index --quiet HEAD