diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:06:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:46:47 +1200 |
commit | c8ab406749124d2e762ad5cf53963070113afd0f (patch) | |
tree | 54c9721a06957ebe7098a211eea803b0230c0f5d /bin/grc.sh | |
parent | Handle POSIX correctness in ~/.bash_profile (diff) | |
download | dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.tar.gz dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.zip |
Apply runtime shebanging to POSIX shell
Diffstat (limited to 'bin/grc.sh')
-rw-r--r-- | bin/grc.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/grc.sh b/bin/grc.sh new file mode 100644 index 00000000..184baf8e --- /dev/null +++ b/bin/grc.sh @@ -0,0 +1,15 @@ +# 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 + +# 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 |