main.c (c5d5393c) main.c (0e7d3a01)
1/* $OpenBSD: main.c,v 1.33 2004/12/20 11:34:26 otto Exp $ */
1/* $OpenBSD: main.c,v 1.34 2004/12/22 17:14:34 millert Exp $ */
2
3/*
4 * startup, main loop, environments and error handling
5 */
6
7#define EXTERN /* define EXTERNs in sh.h */
8
9#include "sh.h"

--- 307 unchanged lines hidden (view full) ---

317 Flag(FRESTRICTED) = 0;
318 errexit = Flag(FERREXIT);
319 Flag(FERREXIT) = 0;
320
321 /* Do this before profile/$ENV so that if it causes problems in them,
322 * user will know why things broke.
323 */
324 if (!current_wd[0] && Flag(FTALKING))
2
3/*
4 * startup, main loop, environments and error handling
5 */
6
7#define EXTERN /* define EXTERNs in sh.h */
8
9#include "sh.h"

--- 307 unchanged lines hidden (view full) ---

317 Flag(FRESTRICTED) = 0;
318 errexit = Flag(FERREXIT);
319 Flag(FERREXIT) = 0;
320
321 /* Do this before profile/$ENV so that if it causes problems in them,
322 * user will know why things broke.
323 */
324 if (!current_wd[0] && Flag(FTALKING))
325 warningf(FALSE, "Cannot determine current working directory");
325 warningf(false, "Cannot determine current working directory");
326
327 if (Flag(FLOGIN)) {
328 include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1);
329 if (!Flag(FPRIVILEGED))
330 include(substitute("$HOME/.profile", 0), 0,
331 (char **) 0, 1);
332 }
333

--- 31 unchanged lines hidden (view full) ---

365 Flag(FERREXIT) = 1;
366
367 if (Flag(FTALKING)) {
368 hist_init(s);
369 alarm_init();
370 } else
371 Flag(FTRACKALL) = 1; /* set after ENV */
372
326
327 if (Flag(FLOGIN)) {
328 include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1);
329 if (!Flag(FPRIVILEGED))
330 include(substitute("$HOME/.profile", 0), 0,
331 (char **) 0, 1);
332 }
333

--- 31 unchanged lines hidden (view full) ---

365 Flag(FERREXIT) = 1;
366
367 if (Flag(FTALKING)) {
368 hist_init(s);
369 alarm_init();
370 } else
371 Flag(FTRACKALL) = 1; /* set after ENV */
372
373 shell(s, TRUE); /* doesn't return */
373 shell(s, true); /* doesn't return */
374 return 0;
375}
376
377int
378include(const char *name, int argc, char **argv, int intr_ok)
379{
380 Source *volatile s = NULL;
381 struct shf *shf;

--- 45 unchanged lines hidden (view full) ---

427 }
428 if (argv) {
429 e->loc->argv = argv;
430 e->loc->argc = argc;
431 }
432 s = pushs(SFILE, ATEMP);
433 s->u.shf = shf;
434 s->file = str_save(name, ATEMP);
374 return 0;
375}
376
377int
378include(const char *name, int argc, char **argv, int intr_ok)
379{
380 Source *volatile s = NULL;
381 struct shf *shf;

--- 45 unchanged lines hidden (view full) ---

427 }
428 if (argv) {
429 e->loc->argv = argv;
430 e->loc->argc = argc;
431 }
432 s = pushs(SFILE, ATEMP);
433 s->u.shf = shf;
434 s->file = str_save(name, ATEMP);
435 i = shell(s, FALSE);
435 i = shell(s, false);
436 shf_close(s->u.shf);
437 quitenv();
438 if (old_argv) {
439 e->loc->argv = old_argv;
440 e->loc->argc = old_argc;
441 }
442 return i & 0xff; /* & 0xff to ensure value not -1 */
443}
444
445int
446command(const char *comm)
447{
448 Source *s;
449
450 s = pushs(SSTRING, ATEMP);
451 s->start = s->str = comm;
436 shf_close(s->u.shf);
437 quitenv();
438 if (old_argv) {
439 e->loc->argv = old_argv;
440 e->loc->argc = old_argc;
441 }
442 return i & 0xff; /* & 0xff to ensure value not -1 */
443}
444
445int
446command(const char *comm)
447{
448 Source *s;
449
450 s = pushs(SSTRING, ATEMP);
451 s->start = s->str = comm;
452 return shell(s, FALSE);
452 return shell(s, false);
453}
454
455/*
456 * run the commands from the input source, returning status.
457 */
458int
459shell(Source *volatile s, volatile int toplevel)
460{

--- 276 unchanged lines hidden ---
453}
454
455/*
456 * run the commands from the input source, returning status.
457 */
458int
459shell(Source *volatile s, volatile int toplevel)
460{

--- 276 unchanged lines hidden ---