/* * print a useful (?) error message, and then die */ void error (const char *msg) { printwhere (); f_print (stderr, "%s, line %d: ", infilename, linenum); f_print (stderr, "%s\n", msg); crash (); }
static int ParseBrowser(SEXP CExpr, SEXP rho) { int rval = 0; if (isSymbol(CExpr)) { const char *expr = CHAR(PRINTNAME(CExpr)); if (!strcmp(expr, "c") || !strcmp(expr, "cont")) { rval = 1; SET_RDEBUG(rho, 0); } else if (!strcmp(expr, "f")) { rval = 1; RCNTXT *cntxt = R_GlobalContext; while (cntxt != R_ToplevelContext && !(cntxt->callflag & (CTXT_RETURN | CTXT_LOOP))) { cntxt = cntxt->nextcontext; } cntxt->browserfinish = 1; SET_RDEBUG(rho, 1); R_BrowserLastCommand = 'f'; } else if (!strcmp(expr, "help")) { rval = 2; printBrowserHelp(); } else if (!strcmp(expr, "n")) { rval = 1; SET_RDEBUG(rho, 1); R_BrowserLastCommand = 'n'; } else if (!strcmp(expr, "Q")) { /* Run onexit/cend code for everything above the target. The browser context is still on the stack, so any error will drop us back to the current browser. Not clear this is a good thing. Also not clear this should still be here now that jump_to_toplevel is used for the jump. */ R_run_onexits(R_ToplevelContext); /* this is really dynamic state that should be managed as such */ SET_RDEBUG(rho, 0); /*PR#1721*/ jump_to_toplevel(); } else if (!strcmp(expr, "s")) { rval = 1; SET_RDEBUG(rho, 1); R_BrowserLastCommand = 's'; } else if (!strcmp(expr, "where")) { rval = 2; printwhere(); /* SET_RDEBUG(rho, 1); */ } } return rval; }
/* * WHICH COMMAND */ void printwhich() { printwhere(); }
/** * built-in commands: exit, in, out, bg, fg, jobs, kill * returns 1 if a built-in command is executed, * 0 otherwise */ int checkBuiltInCommands() { if (strcmp("history", commandArgv[0]) == 0) { ReversePrint(); } if (strcmp("alias", commandArgv[0]) == 0) { return 0; } if(strcmp("which", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) { printf("R-Shell: Missing Parameters\n"); } else { printwhich(); } return 1; } if(strcmp("where", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) { printf("R-Shell: Missing Parameters\n"); } else { printwhere(); } return 1; } if(strcmp("setenv", commandArgv[0]) == 0) { envset(); return 1; } if(strcmp("printenv", commandArgv[0]) == 0) { envprint(); return 1; } if (strcmp("pid", commandArgv[0]) == 0) { printpid(); return 1; } if (strcmp("pwd", commandArgv[0]) == 0) { printpwd(); return 1; } if (strcmp("prompt", commandArgv[0]) == 0) { promptCmd(); return 1; } if (strcmp("exit", commandArgv[0]) == 0) { exit(EXIT_SUCCESS); } if (strcmp("cd", commandArgv[0]) == 0) { changeDirectory(); return 1; } if (strcmp("kill", commandArgv[0]) == 0) { if (commandArgv[1] == NULL) return 0; killJob(atoi(commandArgv[1])); return 1; } if (strcmp("ls", commandArgv[0]) == 0) { return 0; } if (strcmp("cd", commandArgv[0]) == 0) { return 0; } return 0; }