about summary refs log tree commit diff
path: root/Functions/Zftp/zfopen
blob: fa9b4f81d5a4a93cc57a01dea91df472ebe0e25f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# function zfopen {
# Use zftp params to set parameters for open, rather than sending
# them straight to open.  That way they are stored for a future open
# command.
#
# With option -1 (just this 1ce), don't do that.

emulate -L zsh

local optlist opt once

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
done

# This is where we should try and do same name-lookupage in
# both .netrc and .ncftp/bookmarks .  We could even try saving
# the info in their for new hosts, like ncftp does.

if [[ $once = 1 ]]; then
  zftp open $*
else
  # set parameters, but only if there was at least a host
  (( $# > 0 )) && zfparams $*
  # now call with no parameters
  zftp open
fi
# }