예제 #1
0
STATIC void
read_profile(const char *name)
{
	int fd;
	int xflag_set = 0;
	int vflag_set = 0;

	if (*name == '\0')
		return;

	INTOFF;
	if ((fd = open(name, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	INTON;
	if (fd < 0)
		return;
	/* -q turns off -x and -v just when executing init files */
	if (qflag)  {
	    if (xflag)
		    xflag = 0, xflag_set = 1;
	    if (vflag)
		    vflag = 0, vflag_set = 1;
	}
	(void)set_dot_funcnest(1);	/* allow profile to "return" */
	cmdloop(0);
	(void)set_dot_funcnest(0);
	if (qflag)  {
	    if (xflag_set)
		    xflag = 1;
	    if (vflag_set)
		    vflag = 1;
	}
	popfile();
}
예제 #2
0
파일: main.c 프로젝트: dezelin/kBuild
STATIC void
read_profile(const char *name)
{
	int fd;
	int xflag_set = 0;
	int vflag_set = 0;

	INTOFF;
	if ((fd = open(name, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	INTON;
	if (fd < 0)
		return;
	/* -q turns off -x and -v just when executing init files */
	if (qflag)  {
	    if (xflag)
		    xflag = 0, xflag_set = 1;
	    if (vflag)
		    vflag = 0, vflag_set = 1;
	}
	cmdloop(0);
	if (qflag)  {
	    if (xflag_set)
		    xflag = 1;
	    if (vflag_set)
		    vflag = 1;
	}
	popfile();
}
예제 #3
0
파일: input.c 프로젝트: AgamAgarwal/minix
void
setinputfile(char *fname, int push)
{
	int fd;
	int fd2;
	struct stat statbuf;
	int saved_errno;

	INTOFF;
	if ((fd = open(fname, O_RDONLY)) < 0)
		error("Can't open %s: %s", fname, strerror(errno));
	if (fstat(fd, &statbuf) < 0) {
		saved_errno = errno;
		close(fd);
		error("Can't stat %s: %s", fname, strerror(saved_errno));
	}
	if (!S_ISREG(statbuf.st_mode)) {
		close(fd);
		error("Can't open %s: %s", fname, strerror(ENOEXEC));
	}
	if (fd < 10) {
		fd2 = fcntl(fd, F_DUPFD, 10);
		close(fd);
		if (fd2 < 0)
			error("Out of file descriptors");
		fd = fd2;
	}
	setinputfd(fd, push);
	INTON;
}
예제 #4
0
파일: main.c 프로젝트: dezelin/kBuild
STATIC void
read_profile(struct shinstance *psh, const char *name)
{
	int fd;
	int xflag_set = 0;
	int vflag_set = 0;

	INTOFF;
	if ((fd = shfile_open(&psh->fdtab, name, O_RDONLY, 0)) >= 0)
		setinputfd(psh, fd, 1);
	INTON;
	if (fd < 0)
		return;
	/* -q turns off -x and -v just when executing init files */
	if (qflag(psh))  {
	    if (xflag(psh))
		    xflag(psh) = 0, xflag_set = 1;
	    if (vflag(psh))
		    vflag(psh) = 0, vflag_set = 1;
	}
	cmdloop(psh, 0);
	if (qflag(psh))  {
	    if (xflag_set)
		    xflag(psh) = 1;
	    if (vflag_set)
		    vflag(psh) = 1;
	}
	popfile(psh);
}
예제 #5
0
파일: main.c 프로젝트: daniloegea/freebsd
void
readcmdfile(const char *name)
{
	int fd;

	INTOFF;
	if ((fd = open(name, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	else
		error("cannot open %s: %s", name, strerror(errno));
	INTON;
	cmdloop(0);
	popfile();
}
예제 #6
0
파일: main.c 프로젝트: iriina/DragonFlyBSD
static void
read_profile(const char *name)
{
	int fd;

	INTOFF;
	if ((fd = open(name, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	INTON;
	if (fd < 0)
		return;
	cmdloop(0);
	popfile();
}
예제 #7
0
파일: main.c 프로젝트: dezelin/kBuild
void
readcmdfile(char *name)
{
	int fd;

	INTOFF;
	if ((fd = open(name, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	else
		error("Can't open %s", name);
	INTON;
	cmdloop(0);
	popfile();
}
예제 #8
0
파일: main.c 프로젝트: dezelin/kBuild
void
readcmdfile(struct shinstance *psh, char *name)
{
	int fd;

	INTOFF;
	if ((fd = shfile_open(&psh->fdtab, name, O_RDONLY, 0)) >= 0)
		setinputfd(psh, fd, 1);
	else
		error(psh, "Can't open %s", name);
	INTON;
	cmdloop(psh, 0);
	popfile(psh);
}
예제 #9
0
파일: main.c 프로젝트: daniloegea/freebsd
static void
read_profile(char *name)
{
	int fd;
	const char *expandedname;

	expandedname = expandstr(name);
	if (expandedname == NULL)
		return;
	INTOFF;
	if ((fd = open(expandedname, O_RDONLY)) >= 0)
		setinputfd(fd, 1);
	INTON;
	if (fd < 0)
		return;
	cmdloop(0);
	popfile();
}
예제 #10
0
파일: input.c 프로젝트: AhmadTux/freebsd
void
setinputfile(const char *fname, int push)
{
	int fd;
	int fd2;

	INTOFF;
	if ((fd = open(fname, O_RDONLY)) < 0)
		error("cannot open %s: %s", fname, strerror(errno));
	if (fd < 10) {
		fd2 = fcntl(fd, F_DUPFD, 10);
		close(fd);
		if (fd2 < 0)
			error("Out of file descriptors");
		fd = fd2;
	}
	setinputfd(fd, push);
	INTON;
}
예제 #11
0
파일: input.c 프로젝트: saltstar/smartnix
int
setinputfile(const char *fname, int flags)
{
	int fd;

	INTOFF;
	if ((fd = open(fname, O_RDONLY)) < 0) {
		if (flags & INPUT_NOFILE_OK)
			goto out;
		exitstatus = 127;
		exerror(EXERROR, "Can't open %s", fname);
	}
	if (fd < 10)
		fd = savefd(fd, fd);
	setinputfd(fd, flags & INPUT_PUSH_FILE);
out:
	INTON;
	return fd;
}
예제 #12
0
static void
read_profile(const char *name)
{
	int fd;
	const char *expandedname;

	expandedname = expandstr(__DECONST(char *, name));
	if (expandedname == NULL)
		return;
	INTOFF;
#ifndef O_CLOEXEC
	if ((fd = open(expandedname, O_RDONLY)) >= 0)
#else
	if ((fd = open(expandedname, O_RDONLY | O_CLOEXEC)) >= 0)
#endif
		setinputfd(fd, 1);
	INTON;
	if (fd < 0)
		return;
	cmdloop(0);
	popfile();
}