summaryrefslogtreecommitdiff
path: root/Functions/Zftp/zfanon
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-05-08 10:45:02 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-05-08 10:45:02 +0000
commit17d342160ae1c59687b61332bd4dee5e62bd509a (patch)
tree7ca5430438165cd96abb44d1d201819438625f11 /Functions/Zftp/zfanon
parentcfcb3202ef71040a7019609da6cb21de57f16ad6 (diff)
downloadzsh-17d342160ae1c59687b61332bd4dee5e62bd509a.tar.gz
zsh-17d342160ae1c59687b61332bd4dee5e62bd509a.zip
11252: no colon at the end of zftp function contexts
Diffstat (limited to 'Functions/Zftp/zfanon')
-rw-r--r--Functions/Zftp/zfanon44
1 files changed, 22 insertions, 22 deletions
diff --git a/Functions/Zftp/zfanon b/Functions/Zftp/zfanon
index d8a9d06a3..5dc22617c 100644
--- a/Functions/Zftp/zfanon
+++ b/Functions/Zftp/zfanon
@@ -2,31 +2,20 @@
emulate -L zsh
-local opt optlist once
+[[ $curcontext = :zf* ]] || local curcontext=:zfanon
+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 +27,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...
@@ -61,10 +51,20 @@ if [[ -z $EMAIL_ADDR ]]; then
print "Using $EMAIL_ADDR as anonymous FTP password."
fi
-if [[ $once = 1 ]]; then
- zftp open $1 anonymous $EMAIL_ADDR
+if [[ $1 = */* ]]; then
+ 1=${1##ftp://}
+ dir=${1#*/}
+ 1=${1%%/*}
+fi
+
+if [[ $opt_1 = 1 ]]; then
+ zftp open $1 anonymous $EMAIL_ADDR || return 1
else
zftp params $1 anonymous $EMAIL_ADDR
- zftp open
+ zftp open || return 1
+fi
+
+if [[ -n $dir ]]; then
+ zfcd $dir
fi
# }