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 () {
|
function vmail:getoptions () {
|
||||||
local OPTIND
|
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
|
case "${opt}" in
|
||||||
h ) # display help and exit
|
h ) # display help and exit
|
||||||
help
|
help
|
||||||
|
@ -128,21 +128,21 @@ function vmail:getoptions () {
|
||||||
;;
|
;;
|
||||||
f ) # forward to email address
|
f ) # forward to email address
|
||||||
forward=${OPTARG,,}
|
forward=${OPTARG,,}
|
||||||
if [[ $forward_to =~ "@" ]] ; then
|
if [[ $forward =~ "@" ]] ; then
|
||||||
forward_to_mbox=${forward_to%@*}
|
forward_mbox=${forward%@*}
|
||||||
forward_to_domain=${forward_to##*@}
|
forward_domain=${forward##*@}
|
||||||
if [ -z $forward_to_mbox ] ; then
|
if [ -z $forward_mbox ] ; then
|
||||||
echo "ERROR: No local part in $forward_to."
|
echo "ERROR: No local part in $forward."
|
||||||
exit 1
|
exit 1
|
||||||
elif [ -z $forward_to_domain ] ; then
|
elif [ -z $forward_domain ] ; then
|
||||||
echo "ERROR: No domain in $forward_to."
|
echo "ERROR: No domain in $forward."
|
||||||
exit 1
|
exit 1
|
||||||
elif ! vmail::validate_domain $forward_to_domain; then
|
elif ! vmail::validate_domain $forward_domain; then
|
||||||
echo "ERROR: $forward_to_domain is not a valid domain name."
|
echo "ERROR: $forward_domain is not a valid domain name."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: $forward_to is not a valid email."
|
echo "ERROR: $forward is not a valid email."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -150,6 +150,7 @@ function vmail:getoptions () {
|
||||||
glob=${OPTARG,,}
|
glob=${OPTARG,,}
|
||||||
;;
|
;;
|
||||||
k ) # keep
|
k ) # keep
|
||||||
|
keep=${OPTARG}
|
||||||
if [[ $keep != "0" ]] && [[ $keep != "1" ]]; then
|
if [[ $keep != "0" ]] && [[ $keep != "1" ]]; then
|
||||||
echo "ERROR: Invalid save keep setting: -k $keep."
|
echo "ERROR: Invalid save keep setting: -k $keep."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user