[net.bugs.4bsd] using :r in adb

scottha@azure.UUCP (Scott Hankerson) (04/18/84)

Description:
	4.2 Adb looses the first character of some of the arguments
	given to the :r (run) command.  This also affects any attempts
	to redirect input/output from the program.

Repeat-By:
	% adb /bin/echo -
	:r this is a test
	[adb responds with]
	this s test
	:r this is a test >file
	[adb responds with]
	this s test file

Fix:
	While parsing the argument list given to the :r command,
	adb removes the white space between the arguments.  The
	way it does this is to read a character and if it's a
	white space character, read again until it finds a character
	that isn't a white space.  Since adb remembers the last
	character read this should work fine.  The problem is
	that it skips the white space twice in a row, thereby
	loosing the first character of the arguments.

	The fix is to move the first attempt to skip white space
	to before the loop which parses the arguments.  One thing
	to note is that it now does support ":r arg arg>file"
	without a white space before the '>'.

	Now after that miserable explanation of the fix is the diff
	which is all you really care about anyway (right?).

	*** runpcs.c.new	Mon Apr 16 17:14:00 1984
	--- runpcs.c.old	Mon Apr 16 17:03:18 1984
	***************
	*** 169,176
		extern STRING environ;
		ap=argl; p=args;
		*ap++=symfil;
	! 	IF rdc()!=EOR THEN 
	! 	REP
			*ap = p;
			/*
			 * First thing is to look for direction characters

	--- 169,175 -----
		extern STRING environ;
		ap=argl; p=args;
		*ap++=symfil;
	! 	REP	IF rdc()==EOR THEN break; FI
			*ap = p;
			/*
			 * First thing is to look for direction characters
	***************
	*** 208,214
			WHILE lastc==SP ORF lastc==TB DO readchar(); OD
	  
		PER lastc!=EOR DONE
	- 	FI
		*ap++=0;
		exect(symfil, argl, environ);
		perror(symfil);

	--- 207,212 -----
			WHILE lastc==SP ORF lastc==TB DO readchar(); OD
	  
		PER lastc!=EOR DONE
		*ap++=0;
		exect(symfil, argl, environ);
		perror(symfil);

scottha@azure.UUCP (Scott Hankerson) (04/18/84)

When I posted my article on adb I forgot to explicitly state
the name of the file that I changed.  Well the file is:
/usr/src/bin/adb/runpcs.c.  Sorry about that (please forgive
me, I didn't mean to do it . . . really!)