diff options
Diffstat (limited to 'Functions/Zftp/zfanon')
-rw-r--r-- | Functions/Zftp/zfanon | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/Functions/Zftp/zfanon b/Functions/Zftp/zfanon index 9624d48d9..f5754dda6 100644 --- a/Functions/Zftp/zfanon +++ b/Functions/Zftp/zfanon @@ -2,31 +2,19 @@ emulate -L zsh -local opt optlist once dir +local opt opt_1 dir -while [[ $1 = -* ]]; do - if [[ $1 = - || $1 = -- ]]; then - shift; - break; - fi - optlist=${1#-} - for (( i = 1; i <= $#optlist; i++)); do - opt=$optlist[$i] - case $optlist[$i] in - 1) once=1 - ;; - *) print option $opt not recognised >&2 - ;; - esac - done - shift +while getopts :1 opt; do + [[ $opt = "?" ]] && print "zfanon: bad option: -$OPTARG" >&2 && return 1 + eval "opt_$opt=1" done +(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) if [[ -z $EMAIL_ADDR ]]; then # Exercise in futility. There's a poem by Wallace Stevens # called something like `N ways of looking at a blackbird', # where N is somewhere around 0x14 to 0x18. Now zftp is - # ashamed to prsent `N ways of looking at a hostname'. + # ashamed to present `N ways of looking at a hostname'. local domain host # First, maybe we've already got it. Zen-like. if [[ $HOST = *.* ]]; then @@ -38,7 +26,8 @@ if [[ -z $EMAIL_ADDR ]]; then [[ -n $domain ]] && host=$HOST.$domain fi # Next, maybe we've got nlsookup. May not work on LINUX. - [[ -z $host ]] && host=$(nslookup $HOST | awk '/Name:/ { print $2 }') + [[ -z $host ]] && host=$(nslookup $HOST 2>/dev/null | + awk '/Name:/ { print $2 }') if [[ -z $host ]]; then # we're running out of ideas, but this should work. # after all, i wrote it... @@ -67,7 +56,7 @@ if [[ $1 = */* ]]; then 1=${1%%/*} fi -if [[ $once = 1 ]]; then +if [[ $opt_1 = 1 ]]; then zftp open $1 anonymous $EMAIL_ADDR || return 1 else zftp params $1 anonymous $EMAIL_ADDR |