Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/distrib/utils/sysinst/Attic/run.c,v rcsdiff: /ftp/cvs/cvsroot/src/distrib/utils/sysinst/Attic/run.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.55.2.2.2.1 retrieving revision 1.56 diff -u -p -r1.55.2.2.2.1 -r1.56 --- src/distrib/utils/sysinst/Attic/run.c 2005/07/24 02:25:24 1.55.2.2.2.1 +++ src/distrib/utils/sysinst/Attic/run.c 2004/05/15 21:51:30 1.56 @@ -1,4 +1,4 @@ -/* $NetBSD: run.c,v 1.55.2.2.2.1 2005/07/24 02:25:24 snj Exp $ */ +/* $NetBSD: run.c,v 1.56 2004/05/15 21:51:30 dsl Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -266,14 +266,6 @@ make_argv(const char *cmd) if (argv == NULL) err(1, "realloc(argv) for %s", cmd); asprintf(argv + argc, "%.*s", (int)(cp - cmd), cmd); - /* Hack to remove %xx encoded ftp password */ - dp = strstr(cmd, ":%"); - if (dp != NULL && dp < cp) { - for (fn = dp + 4; *fn == '%'; fn += 3) - continue; - if (*fn == '@') - memset(dp + 1, '*', fn - dp - 1); - } if (*cp == '\'') cp++; if (cp[-1] != '*') @@ -327,39 +319,38 @@ show_cmd(const char *scmd, struct winsiz { int n, m; WINDOW *actionwin; - int nrow; wclear(stdscr); clearok(stdscr, 1); touchwin(stdscr); refresh(); + actionwin = subwin(stdscr, win->ws_row - 4, win->ws_col, 4, 0); + if (actionwin == NULL) { + fprintf(stderr, "sysinst: failed to allocate" + " output window.\n"); + exit(1); + } + scrollok(actionwin, TRUE); + if (has_colors()) { + wbkgd(actionwin, getbkgd(stdscr)); + wattrset(actionwin, getattrs(stdscr)); + } + mvaddstr(0, 4, msg_string(MSG_Status)); standout(); addstr(msg_string(MSG_Running)); standend(); mvaddstr(1, 4, msg_string(MSG_Command)); standout(); - printw("%s", scmd); + printw("%.*s", win->ws_col - getcurx(stdscr) - 1, scmd); standend(); - addstr("\n\n"); + + move(3, 0); for (n = win->ws_col; (m = min(n, 30)) > 0; n -= m) addstr( "------------------------------" + 30 - m); refresh(); - nrow = getcury(stdscr) + 1; - - actionwin = subwin(stdscr, win->ws_row - nrow, win->ws_col, nrow, 0); - if (actionwin == NULL) { - fprintf(stderr, "sysinst: failed to allocate output window.\n"); - exit(1); - } - scrollok(actionwin, TRUE); - if (has_colors()) { - wbkgd(actionwin, getbkgd(stdscr)); - wattrset(actionwin, getattrs(stdscr)); - } - wmove(actionwin, 0, 0); wrefresh(actionwin); @@ -414,11 +405,6 @@ launch_subwin(WINDOW **actionwin, char * } } - if (logging) - fflush(logfp); - if (scripting) - fflush(script); - child = fork(); switch (child) { case -1: @@ -439,23 +425,27 @@ launch_subwin(WINDOW **actionwin, char * (void)tcsetattr(slave, TCSANOW, &rtt); login_tty(slave); if (logging) { - fprintf(logfp, "executing: %s\n", scmd); + fprintf(logfp, "executing:"); + for (i = 0; args[i]; i++) + fprintf(logfp, " %s", args[i]); + fprintf(logfp, "\n"); fclose(logfp); } if (scripting) { - fprintf(script, "%s\n", scmd); + for (i = 0; args[i]; i++) + fprintf(script, "%s ", args[i]); + fprintf(script, "\n"); fclose(script); } /* * If target_prefix == "", the chroot will fail, but * that's ok, since we don't need it then. */ - if ((flags & RUN_CHROOT) != 0 && chroot(target_prefix()) != 0) - warn("chroot(%s) for %s", target_prefix(), *args); - else { - execvp(*args, args); - warn("execvp %s", *args); - } + if ((flags & RUN_CHROOT) != 0) + chroot(target_prefix()); + execvp(*args, args); + /* The parent will see this as the output from the child */ + warn("execvp %s", *args); _exit(EXIT_FAILURE); break; /* end of child */ default: @@ -563,6 +553,7 @@ loop: * RUN_CHROOT chroot to target before the exec * RUN_FULLSCREEN display output only * RUN_SILENT do not display program output + * RUN_DISPLAY_ERR display status if program fails * RUN_ERROR_OK don't wait for key if program fails * RUN_PROGRESS don't wait for key if program has output * If both RUN_DISPLAY and RUN_SILENT are clear then the program name will @@ -614,44 +605,34 @@ run_program(int flags, const char *cmd, ret = launch_subwin(&actionwin, args, &win, flags, scmd, &errstr); /* If the command failed, show command name */ - if (actionwin == NULL && ret != 0 && !(flags & RUN_ERROR_OK)) + if (ret != 0 && actionwin == NULL && !(flags & RUN_SILENT_ERR)) actionwin = show_cmd(scmd, &win); if (actionwin != NULL) { int y, x; getyx(actionwin, y, x); - if (actionwin != stdscr) - mvaddstr(0, 4, msg_string(MSG_Status)); + standout(); if (ret != 0) { - if (actionwin == stdscr && x != 0) + if (actionwin != stdscr) + move(0, 13); + else if (x != 0) addstr("\n"); - x = 1; /* force newline below */ - standout(); addstr(errstr); - standend(); - } else { - if (actionwin != stdscr) { - standout(); - addstr(msg_string(MSG_Finished)); - standend(); - } - } + x = 1; /* force newline below */ + } else + if (actionwin != stdscr) + mvaddstr(0, 13, msg_string(MSG_Finished)); + standend(); refresh(); if ((ret != 0 && !(flags & RUN_ERROR_OK)) || (y + x != 0 && !(flags & RUN_PROGRESS))) { if (actionwin != stdscr) - move(getbegy(actionwin) - 2, 5); + move(2, 5); else if (x != 0) addstr("\n"); addstr(msg_string(MSG_Hit_enter_to_continue)); refresh(); getchar(); - } else { - if (y + x != 0) { - /* give user 1 second to see messages */ - refresh(); - sleep(1); - } } }