fixed forward getopts handling
This commit is contained in:
parent
29e93d3971
commit
1dd687aae8
23
bin/vmail.sh
23
bin/vmail.sh
|
@ -75,7 +75,7 @@ function vmail::yesno() {
|
|||
|
||||
function vmail:getoptions () {
|
||||
local OPTIND
|
||||
while getopts "ha:b:d:e:f:gcp:q:s:tkf:gl:m:vx" opt ; do
|
||||
while getopts "ha:b:d:e:f:gcp:q:s:tk:f:gl:m:vx" opt ; do
|
||||
case "${opt}" in
|
||||
h ) # display help and exit
|
||||
help
|
||||
|
@ -128,21 +128,21 @@ function vmail:getoptions () {
|
|||
;;
|
||||
f ) # forward to email address
|
||||
forward=${OPTARG,,}
|
||||
if [[ $forward_to =~ "@" ]] ; then
|
||||
forward_to_mbox=${forward_to%@*}
|
||||
forward_to_domain=${forward_to##*@}
|
||||
if [ -z $forward_to_mbox ] ; then
|
||||
echo "ERROR: No local part in $forward_to."
|
||||
if [[ $forward =~ "@" ]] ; then
|
||||
forward_mbox=${forward%@*}
|
||||
forward_domain=${forward##*@}
|
||||
if [ -z $forward_mbox ] ; then
|
||||
echo "ERROR: No local part in $forward."
|
||||
exit 1
|
||||
elif [ -z $forward_to_domain ] ; then
|
||||
echo "ERROR: No domain in $forward_to."
|
||||
elif [ -z $forward_domain ] ; then
|
||||
echo "ERROR: No domain in $forward."
|
||||
exit 1
|
||||
elif ! vmail::validate_domain $forward_to_domain; then
|
||||
echo "ERROR: $forward_to_domain is not a valid domain name."
|
||||
elif ! vmail::validate_domain $forward_domain; then
|
||||
echo "ERROR: $forward_domain is not a valid domain name."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "ERROR: $forward_to is not a valid email."
|
||||
echo "ERROR: $forward is not a valid email."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
@ -150,6 +150,7 @@ function vmail:getoptions () {
|
|||
glob=${OPTARG,,}
|
||||
;;
|
||||
k ) # keep
|
||||
keep=${OPTARG}
|
||||
if [[ $keep != "0" ]] && [[ $keep != "1" ]]; then
|
||||
echo "ERROR: Invalid save keep setting: -k $keep."
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user