int escapade() { register char *s; bool interactive = (buf[1] == FINISHCMD); bool docd; char whereiam[512]; if (!finish_command(interactive)) /* get remainder of command */ return -1; s = buf+1; docd = *s != '!'; if (!docd) { s++; } else { getwd(whereiam); if (chdir(cwd)) { printf(nocd,cwd) FLUSH; sig_catcher(0); } } while (*s == ' ') s++; /* skip leading spaces */ interp(cmd_buf, (sizeof cmd_buf), s);/* interpret any % escapes */ resetty(); /* make sure tty is friendly */ doshell(Nullch,cmd_buf); /* invoke the shell */ noecho(); /* and make terminal */ crmode(); /* unfriendly again */ if (docd) { if (chdir(whereiam)) { printf(nocd,whereiam) FLUSH; sig_catcher(0); } } #ifdef MAILCALL mailcount = 0; /* force recheck */ #endif return 0; }
void backpage_init() { char *varyname; varyname = filexp(VARYNAME); close(creat(varyname,0600)); varyfd = open(varyname,2); UNLINK(varyname); if (varyfd < 0) { printf(cantopen,varyname) FLUSH; sig_catcher(0); } }
int main(int ac, char **av, char **envp) { t_var *var; (void)ac; (void)av; var = get_instance(); init_function(var, envp); init_terminal(var); sig_catcher(); while (18) { ft_putstr_fd("$>", var->conf->wfd); set_str_cap("sc"); terminal_input_mode(var->conf); read_key(var); terminal_execute_mode(var->conf); proceed_to_execution(var); } ft_strdel(&(var->line.cpy)); return (0); }
int switcheroo() { if (!finish_command(TRUE)) /* get rest of command */ return -1; /* if rubbed out, try something else */ if (!buf[1]) pr_switches(); else if (buf[1] == '&') { if (!buf[2]) { page_init(); show_macros(); } else { char tmpbuf[LBUFLEN]; register char *s; for (s=buf+2; isspace(*s); s++); mac_line(s,tmpbuf,(sizeof tmpbuf)); } } else { bool docd = (instr(buf,"-d", TRUE) != Nullch); char whereami[512]; if (docd) getwd(whereami); sw_list(buf+1); if (docd) { cwd_check(); if (chdir(whereami)) { /* -d does chdirs */ printf(nocd,whereami) FLUSH; sig_catcher(0); } } } return 0; }