diff options
author | des <des@FreeBSD.org> | 2000-06-29 10:32:56 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2000-06-29 10:32:56 +0000 |
commit | c8fb726f7671fb521c9ea63b18dbf41df1ab605e (patch) | |
tree | fe4bb2011ca0c22f9f87ac527a867bf6347e8193 /usr.bin/fetch | |
parent | 38b5153ff97b549269285451c58fc4a65720ecce (diff) | |
download | FreeBSD-src-c8fb726f7671fb521c9ea63b18dbf41df1ab605e.zip FreeBSD-src-c8fb726f7671fb521c9ea63b18dbf41df1ab605e.tar.gz |
Implement the -c option
Diffstat (limited to 'usr.bin/fetch')
-rw-r--r-- | usr.bin/fetch/fetch.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 48d3da1..87407ec 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -50,6 +50,7 @@ int A_flag; /* -A: do not follow 302 redirects */ int a_flag; /* -a: auto retry */ size_t B_size; /* -B: buffer size */ int b_flag; /*! -b: workaround TCP bug */ +char *c_dirname; /* -c: remote directory */ int d_flag; /* -d: direct connection */ int F_flag; /* -F: restart without checking mtime */ char *f_filename; /* -f: file to fetch */ @@ -434,7 +435,7 @@ main(int argc, char *argv[]) int c, e, r; while ((c = getopt(argc, argv, - "146AaB:bdFf:h:lHMmnPpo:qRrS:sT:tvw:")) != EOF) + "146AaB:bc:dFf:h:lHMmnPpo:qRrS:sT:tvw:")) != EOF) switch (c) { case '1': once_flag = 1; @@ -459,6 +460,9 @@ main(int argc, char *argv[]) warnx("warning: the -b option is deprecated"); b_flag = 1; break; + case 'c': + c_dirname = optarg; + break; case 'd': d_flag = 1; break; @@ -532,7 +536,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (h_hostname || f_filename) { + if (h_hostname || f_filename || c_dirname) { if (!h_hostname || !f_filename || argc) { usage(); exit(EX_USAGE); @@ -540,7 +544,8 @@ main(int argc, char *argv[]) /* XXX this is a hack. */ if (strcspn(h_hostname, "@:/") != strlen(h_hostname)) errx(1, "invalid hostname"); - if (asprintf(argv, "ftp://%s/%s", h_hostname, f_filename) == -1) + if (asprintf(argv, "ftp://%s/%s/%s", h_hostname, + c_dirname ? c_dirname : "", f_filename) == -1) errx(1, strerror(ENOMEM)); argc++; } |