From 6a0e9249883bb9ea26a0bffbebdb345c444698dc Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 16 Jun 2014 15:24:54 -0400 Subject: [PATCH] Add error handling --- bin/ssh-hosts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/ssh-hosts b/bin/ssh-hosts index bfedd87..8aa19f9 100755 --- a/bin/ssh-hosts +++ b/bin/ssh-hosts @@ -66,7 +66,7 @@ ssh_hosts_for_group () { } show_ssh_groups () { - local groups=($(ssh_groups)) + local readonly groups=($(ssh_groups)) local group local group_number=0 @@ -95,11 +95,21 @@ cmdline () { h) info ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit + ;; *) usage ;; esac done + + if [ $OPTIND -eq 1 ] + then + usage + fi + shift $((OPTIND-1)) }