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/zfuget | 50 +++++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'Functions/Zftp/zfuget') diff --git a/Functions/Zftp/zfuget b/Functions/Zftp/zfuget index 482da42e9..955c48f4a 100644 --- a/Functions/Zftp/zfuget +++ b/Functions/Zftp/zfuget @@ -26,7 +26,7 @@ emulate -L zsh local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuget$$ -local rstat remlist verbose optlist opt bad i silent nglob time +local rstat remlist opt opt_v opt_s opt_G opt_t integer stat do_close zfuget_print_time() { @@ -43,40 +43,20 @@ zfuget_print () { print ", $locstats[1] bytes)" } -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 - v) verbose=1 - ;; - s) silent=1 - ;; - G) nglob=1 - ;; - t) time=1 - ;; - *) print option $opt not recognised >&2 - ;; - esac - done - shift +while getopts :vsGt opt; do + [[ $opt = "?" ]] && print "zfuget: bad option: -$OPTARG" >&2 && return 1 + eval "opt_$opt=1" done +(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) -[[ -n $bad ]] && return 1 - -zfautocheck +zfautocheck || return 1 for remlist in $*; do # zfcd directory hack to put the front back to ~ if [[ $remlist == $HOME || $remlist == $HOME/* ]]; then remlist="~${remlist#$HOME}" fi - if [[ $nglob != 1 ]]; then + if [[ $opt_n != 1 ]]; then zfrglob remlist fi if (( $#remlist )); then @@ -99,11 +79,11 @@ for remlist in $*; do stat=1 continue fi - [[ $verbose = 1 ]] && zfuget_print + [[ $opt_v = 1 ]] && zfuget_print if (( $locstats[1] != $remstats[1] )); then # Files have different sizes - if [[ $locstats[2] > $remstats[2] && $silent != 1 ]]; then - [[ $verbose != 1 ]] && zfuget_print + if [[ $locstats[2] > $remstats[2] && $opt_s != 1 ]]; then + [[ $opt_v != 1 ]] && zfuget_print print "Local file $loc more recent than remote," 1>&2 print -n "but sizes are different. Transfer anyway [y/n]? " 1>&2 read -q doit @@ -111,24 +91,24 @@ for remlist in $*; do else # Files have same size if [[ $locstats[2] < $remstats[2] ]]; then - if [[ $silent != 1 ]]; then - [[ $verbose != 1 ]] && zfuget_print + if [[ $opt_s != 1 ]]; then + [[ $opt_v != 1 ]] && zfuget_print print "Local file $loc has same size as remote," 1>&2 print -n "but local file is older. Transfer anyway [y/n]? " 1>&2 read -q doit fi else # presumably same file, so don't get it. - [[ $verbose = 1 ]] && print Not transferring + [[ $opt_v = 1 ]] && print Not transferring doit=n fi fi else - [[ $verbose = 1 ]] && print New file $loc + [[ $opt_v = 1 ]] && print New file $loc fi if [[ $doit = y ]]; then if zftp get $rem >$loc; then - if [[ $time = 1 ]]; then + if [[ $opt_t = 1 ]]; then # if $remstats is set, it's second element is the remote time zfrtime $loc $rem $remstats[2] fi -- cgit 1.4.1