[net.bugs.4bsd] "put *" doesn't work in FTP

guy@sun.uucp (Guy Harris) (09/26/85)

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 "<whatever>.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