ftp won't always glob

Guy Harris guy at sun.uucp
Mon Nov 11 07:47:08 AEST 1985


> Description:
> 	When processing '!' shell escapes, Ftp globs meta characters 
> 	on its own and does an execvp() instead of handing the command
> 	to a shell. If you give '!' more than one argument, you get 
> 	garbage out. If you give it one arg, the glob still doesn't work.
> 	
> Fix:
> 	I think Guy Harris mentioned this about 7 months ago, but
> 	fixed it by removing the feature and always forking a shell.
> 	I you would rather make it work, here's how.

Why should "ftp" duplicate the actions of the shell?  Other UNIX programs
handle shell escapes by doing an "sh -c" (except "ed", which uses the old
"-t" crock), because that way they don't have to know anything about how the
shell works.  I don't think shell escapes are used enough to make the
performance considerations of bypassing "sh" important.

Also note that to really make shell escapes work right, you also have to
recognize input/output redirection, pipelines, etc., etc. - none of which
"ftp"'s built-in code does.

I suspect the reason "ftp" does its own command parsing is that it's a
halfassed piece of code; note all the bug reports that have been posted.
(And, as the Good Book says, "There's bigger deals to come!"; you may notice
a blank line produced after a command finishes when you use "ftp" on Suns.
This is because, instead of returning from the command loop after executing
a command, it jumps back by doing "longjmp(<whatever>, 0)", and Sun's
"longjmp" converts a second argument of 0 into a second argument of 1, as
the S5 "longjmp" does - thus, the caller of the command loop thinks it got
an error.  I'll fix it to work sanely at some point; there are also some
other bugs found by somebody else here.)

	Guy Harris



More information about the Comp.bugs.4bsd.ucb-fixes mailing list