Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp
Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy
From: guy@sun.uucp (Guy Harris)
Newsgroups: net.bugs.4bsd
Subject: "put *" doesn't work in FTP
Message-ID: <2829@sun.uucp>
Date: Thu, 26-Sep-85 00:50:56 EDT
Article-I.D.: sun.2829
Posted: Thu Sep 26 00:50:56 1985
Date-Received: Sun, 29-Sep-85 04:42:33 EDT
Distribution: net
Organization: Sun Microsystems, Inc.
Lines: 72

Index:	ucb/ftp/cmds.c 4.2BSD

Description:
	It is an undocumented feature of "ftp" that it does expansion
	of star names in some commands.  Star name expansion in "put"
	is useful if the star name expands to one file.  If you say
	something like "put *.c", however, the target file name will
	be "*.c", not ".c".
Repeat-By:
	Try it.
Fix:

*** /tmp/,RCSt1a00289	Wed Sep 25 16:46:15 1985
--- /tmp/,RCSt2a00289	Wed Sep 25 16:46:23 1985
***************
*** 205,210
  	char *argv[];
  {
  	char *cmd;
  
  	if (argc == 2)
  		argc++, argv[2] = argv[1];

--- 205,211 -----
  	char *argv[];
  {
  	char *cmd;
+ 	char *oldargv1;
  
  	if (argc == 2)
  		argc++, argv[2] = argv[1];
***************
*** 231,236
  	}
  	if (argc < 3) 
  		goto usage;
  	if (!globulize(&argv[1]))
  		return;
  	cmd = (argv[0][0] == 'a') ? "APPE" : "STOR";

--- 232,238 -----
  	}
  	if (argc < 3) 
  		goto usage;
+ 	oldargv1 = argv[1];
  	if (!globulize(&argv[1]))
  		return;
  	/*
***************
*** 233,238
  		goto usage;
  	if (!globulize(&argv[1]))
  		return;
  	cmd = (argv[0][0] == 'a') ? "APPE" : "STOR";
  	sendrequest(cmd, argv[1], argv[2]);
  }

--- 235,246 -----
  	oldargv1 = argv[1];
  	if (!globulize(&argv[1]))
  		return;
+ 	/*
+ 	 * If "globulize" modifies argv[1], and argv[2] is a copy of
+ 	 * the old argv[1], make it a copy of the new argv[1].
+ 	 */
+ 	if (argv[1] != oldargv1 && argv[2] == oldargv1)
+ 		argv[2] = argv[1];
  	cmd = (argv[0][0] == 'a') ? "APPE" : "STOR";
  	sendrequest(cmd, argv[1], argv[2]);
  }

	Guy Harris