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(); }
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(); }
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; }
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); }
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(); }
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(); }
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(); }
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); }
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(); }
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; }
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; }
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(); }