From c1a691d965182c34c56140c56f7ea92cce7cf90c Mon Sep 17 00:00:00 2001 From: Cory Boyd Date: Sun, 7 Feb 2016 14:06:55 -0800 Subject: [PATCH] Check for correct number of arguments. Otherwise, print some usage info. --- git-blame-someone-else | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-blame-someone-else b/git-blame-someone-else index 41590e0..d76642c 100644 --- a/git-blame-someone-else +++ b/git-blame-someone-else @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [ $# -ne 2 ]; then + >&2 echo "Usage: $0 " + exit 1 +fi + AUTHOR=$1 AUTHOR_NAME=$(echo $AUTHOR | perl -wlne '/^(.*)\s*<.*>$/ and print $1') AUTHOR_EMAIL=$(echo $AUTHOR | perl -wlne '/^.*\s*<(.*)>$/ and print $1') @@ -11,4 +16,4 @@ COMMIT=$(git rev-parse --short $2) git rebase --continue } &> /dev/null -echo "$AUTHOR_NAME is now the author of $COMMIT. You're officially an asshole."; \ No newline at end of file +echo "$AUTHOR_NAME is now the author of $COMMIT. You're officially an asshole.";