pdp11v/usr/src/cmd/uucp/gwd.c

Compare this file to the similar file:
Show the results in this format:

/* @(#)gwd.c	1.1 */
#include "uucp.h"

/*******
 *	gwd(wkdir)	get working directory
 *
 *	return codes  0 | FAIL
 */

gwd(wkdir)
char *wkdir;
{
	FILE *fp;
	extern FILE *popen();
	char *c;

	*wkdir = '\0';
	if ((fp = popen("pwd 2>&-", "r")) == NULL)
		return(FAIL);
	if (fgets(wkdir, 100, fp) == NULL) {
		pclose(fp);
		return(FAIL);
	}
	if (*(c = wkdir + strlen(wkdir) - 1) == '\n')
		*c = '\0';
	pclose(fp);
	return(0);
}