From 319e8208ef184c58178dcfac753cb5526885bcc4 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Thu, 11 Feb 2021 14:09:07 -0800 Subject: [PATCH] moved getopts up --- bin/vmail-aliases-get.sh | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/bin/vmail-aliases-get.sh b/bin/vmail-aliases-get.sh index 7753028..7b57fac 100755 --- a/bin/vmail-aliases-get.sh +++ b/bin/vmail-aliases-get.sh @@ -27,6 +27,27 @@ help() exit } +# set any options that were passed +while getopts "achs" opt; do + case "${opt}" in + a ) + aliassearch=true + ;; + c ) + cvs="| sed 's/\t/,/g'" + ;; + h ) + help + exit;; + s ) + dbcmdopts="-s -N $dbcmdopts" + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit;; + esac +done + dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE" dbcmdopts="-e" dbquery="SELECT vm_aliases.alias, vm_mboxes.mbox, vm_domains.domain FROM vm_aliases, vm_mboxes, vm_domains WHERE vm_aliases.mbox_id = vm_mboxes.id AND vm_mboxes.domain_id = vm_domains.id" @@ -54,27 +75,6 @@ if [ -n "$1" ]; then fi fi -# set any options that were passed -while getopts "achs" opt; do - case "${opt}" in - a ) - aliassearch=true - ;; - c ) - cvs="| sed 's/\t/,/g'" - ;; - h ) - help - exit;; - s ) - dbcmdopts="-s -N $dbcmdopts" - ;; - \? ) - echo "Invalid option: $OPTARG" 1>&2 - exit;; - esac -done - # build query if [ -n "$domain" ]; then # add specific domain