summaryrefslogtreecommitdiff
path: root/Functions/Zftp/zfgcp
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/zfgcp
parentcfcb3202ef71040a7019609da6cb21de57f16ad6 (diff)
downloadzsh-17d342160ae1c59687b61332bd4dee5e62bd509a.tar.gz
zsh-17d342160ae1c59687b61332bd4dee5e62bd509a.zip
11252: no colon at the end of zftp function contexts
Diffstat (limited to 'Functions/Zftp/zfgcp')
-rw-r--r--Functions/Zftp/zfgcp34
1 files changed, 12 insertions, 22 deletions
diff --git a/Functions/Zftp/zfgcp b/Functions/Zftp/zfgcp
index 26a08697d..c9045c951 100644
--- a/Functions/Zftp/zfgcp
+++ b/Functions/Zftp/zfgcp
@@ -16,30 +16,17 @@
emulate -L zsh
-local opt optlist nglob remlist rem loc time
+[[ $curcontext = :zf* ]] || local curcontext=:zfgcp
+local opt remlist rem loc opt_G opt_t
integer stat do_close
-while [[ $1 == -* ]]; do
- if [[ $1 == - || $1 == -- ]]; then
- shift;
- break;
- fi
- optlist=${1#-}
- for (( i = 1; i <= $#optlist; i++)); do
- opt=$optlist[$i]
- case $opt in
- G) nglob=1
- ;;
- t) time=1
- ;;
- *) print option $opt not recognised >&2
- ;;
- esac
- done
- shift
+while getopts :Gt opt; do
+ [[ $opt = '?' ]] && print "zfgcp: bad option: -$OPTARG" >&2 && return 1
+ eval "opt_$opt=1"
done
+(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
-zfautocheck
+zfautocheck || return 1
# hmm, we should really check this after expanding the glob,
# but we shouldn't expand the last argument remotely anyway.
@@ -59,14 +46,14 @@ if [[ -d $argv[-1] ]]; then
if [[ $remlist = $HOME || $remlist = $HOME/* ]]; then
remlist="~${remlist#$HOME}"
fi
- if [[ $nglob != 1 ]]; then
+ if [[ $opt_G != 1 ]]; then
zfrglob remlist
fi
if (( $#remlist )); then
for rem in $remlist; do
loc=$dir/${rem:t}
if zftp get $rem >$loc; then
- [[ $time = 1 ]] && zfrtime $rem $loc
+ [[ $opt_t = 1 ]] && zfrtime $rem $loc
else
stat=1
fi
@@ -74,6 +61,9 @@ if [[ -d $argv[-1] ]]; then
fi
done
else
+ if [[ $1 = $HOME || $1 = $HOME/* ]]; then
+ 1="~${1#$HOME}"
+ fi
zftp get $1 >$2 || stat=$?
fi