From b67e4abb100f67ca05809baab37700eb5ee0a342 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 10 Sep 1999 13:57:31 +0000 Subject: manual/7767 --- Functions/Zftp/zfopen | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'Functions/Zftp/zfopen') diff --git a/Functions/Zftp/zfopen b/Functions/Zftp/zfopen index b264aeaba..32b450411 100644 --- a/Functions/Zftp/zfopen +++ b/Functions/Zftp/zfopen @@ -7,25 +7,13 @@ emulate -L zsh -local optlist opt once dir +local opt dir opt_1 -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 "zfopen: bad option: -$OPTARG" >&2 && return 1 + eval "opt_$opt=1" done +(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) # This is where we should try and do same name-lookupage in # both .netrc and .ncftp/bookmarks . We could even try saving @@ -37,8 +25,14 @@ if [[ $1 = */* ]]; then 1=${1%%/*} fi -if [[ $once = 1 ]]; then +if [[ $opt_1 = 1 ]]; then zftp open $* || return 1 + if [[ $# = 1 ]]; then + if ! zftp login; then + zftp close + return 1 + fi + fi else # set parameters, but only if there was at least a host (( $# > 0 )) && zfparams $* -- cgit 1.4.1