Subversion Repositories SvarDOS

Rev

Rev 474 | Rev 479 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 474 Rev 475
Line 419... Line 419...
419
    for (i = 0; cmdtail[i] != 0; i++) rmod->batargs[i] = cmdtail[i];
419
    for (i = 0; cmdtail[i] != 0; i++) rmod->batargs[i] = cmdtail[i];
420
    /* reset the 'next line to execute' counter */
420
    /* reset the 'next line to execute' counter */
421
    rmod->batnextline = 0;
421
    rmod->batnextline = 0;
422
    /* remember the echo flag (in case bat file disables echo) */
422
    /* remember the echo flag (in case bat file disables echo) */
423
    rmod->flags &= ~FLAG_ECHO_BEFORE_BAT;
423
    rmod->flags &= ~FLAG_ECHO_BEFORE_BAT;
424
    if (rmod->echoflag) rmod->flags |= FLAG_ECHO_BEFORE_BAT;
424
    if (rmod->flags & FLAG_ECHOFLAG) rmod->flags |= FLAG_ECHO_BEFORE_BAT;
425
    return;
425
    return;
426
  }
426
  }
427
 
427
 
428
  /* copy full filename to execute */
428
  /* copy full filename to execute */
429
  for (i = 0; cmdfile[i] != 0; i++) rmod_execprog[i] = cmdfile[i];
429
  for (i = 0; cmdfile[i] != 0; i++) rmod_execprog[i] = cmdfile[i];
Line 623... Line 623...
623
      outputnl("ERROR: rmod_install() failed");
623
      outputnl("ERROR: rmod_install() failed");
624
      return(1);
624
      return(1);
625
    }
625
    }
626
    /* look at command line parameters */
626
    /* look at command line parameters */
627
    parse_argv(&cfg);
627
    parse_argv(&cfg);
628
    /* copy flags to rmod's storage */
628
    /* copy flags to rmod's storage (and enable ECHO) */
629
    rmod->flags = cfg.flags;
629
    rmod->flags = cfg.flags | FLAG_ECHOFLAG;
630
    /* printf("rmod installed at %Fp\r\n", rmod); */
630
    /* printf("rmod installed at %Fp\r\n", rmod); */
631
  } else {
631
  } else {
632
    /* printf("rmod found at %Fp\r\n", rmod); */
632
    /* printf("rmod found at %Fp\r\n", rmod); */
633
    /* if I was spawned by rmod and FLAG_EXEC_AND_QUIT is set, then I should
633
    /* if I was spawned by rmod and FLAG_EXEC_AND_QUIT is set, then I should
634
     * die asap, because the command has been executed already, so I no longer
634
     * die asap, because the command has been executed already, so I no longer
Line 651... Line 651...
651
  }*/
651
  }*/
652
 
652
 
653
  do {
653
  do {
654
    char far *cmdline;
654
    char far *cmdline;
655
 
655
 
656
    if (rmod->echoflag != 0) outputnl(""); /* terminate the previous command with a CR/LF */
656
    if (rmod->flags & FLAG_ECHOFLAG) outputnl(""); /* terminate the previous command with a CR/LF */
657
 
657
 
658
    SKIP_NEWLINE:
658
    SKIP_NEWLINE:
659
 
659
 
660
    /* cancel any redirections that may have been set up before */
660
    /* cancel any redirections that may have been set up before */
661
    redir_revert();
661
    redir_revert();
Line 676... Line 676...
676
    if (rmod->batfile[0] != 0) {
676
    if (rmod->batfile[0] != 0) {
677
      char *tmpbuff = BUFFER + sizeof(BUFFER) - 256;
677
      char *tmpbuff = BUFFER + sizeof(BUFFER) - 256;
678
      if (getbatcmd(tmpbuff, rmod) != 0) { /* end of batch */
678
      if (getbatcmd(tmpbuff, rmod) != 0) { /* end of batch */
679
        redir_revert(); /* cancel redirections (if there were any) */
679
        redir_revert(); /* cancel redirections (if there were any) */
680
        /* restore echo flag as it was before running the bat file */
680
        /* restore echo flag as it was before running the bat file */
681
        rmod->echoflag = 0;
681
        rmod->flags &= ~FLAG_ECHOFLAG;
682
        if (rmod->flags & FLAG_ECHO_BEFORE_BAT) rmod->echoflag = 1;
682
        if (rmod->flags & FLAG_ECHO_BEFORE_BAT) rmod->flags |= FLAG_ECHOFLAG;
683
        continue;
683
        continue;
684
      }
684
      }
685
      /* output prompt and command on screen if echo on and command is not
685
      /* output prompt and command on screen if echo on and command is not
686
       * inhibiting it with the @ prefix */
686
       * inhibiting it with the @ prefix */
687
      if ((rmod->echoflag != 0) && (tmpbuff[1] != '@')) {
687
      if ((rmod->flags & FLAG_ECHOFLAG) && (tmpbuff[1] != '@')) {
688
        build_and_display_prompt(BUFFER, *rmod_envseg);
688
        build_and_display_prompt(BUFFER, *rmod_envseg);
689
        outputnl(tmpbuff + 1);
689
        outputnl(tmpbuff + 1);
690
      }
690
      }
691
      /* strip the @ prefix if present, it is no longer useful */
691
      /* strip the @ prefix if present, it is no longer useful */
692
      if (tmpbuff[1] == '@') {
692
      if (tmpbuff[1] == '@') {
Line 695... Line 695...
695
      }
695
      }
696
      cmdline = tmpbuff + 1;
696
      cmdline = tmpbuff + 1;
697
    } else {
697
    } else {
698
      /* interactive mode: display prompt (if echo enabled) and wait for user
698
      /* interactive mode: display prompt (if echo enabled) and wait for user
699
       * command line */
699
       * command line */
700
      if (rmod->echoflag != 0) build_and_display_prompt(BUFFER, *rmod_envseg);
700
      if (rmod->flags & FLAG_ECHOFLAG) build_and_display_prompt(BUFFER, *rmod_envseg);
701
      /* revert input history terminator to \r so DOS or DOSKEY are not confused */
701
      /* revert input history terminator to \r so DOS or DOSKEY are not confused */
702
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
702
      cmdline[(unsigned short)(cmdline[-1])] = '\r';
703
      /* collect user input */
703
      /* collect user input */
704
      cmdline_getinput(FP_SEG(rmod->inputbuf), FP_OFF(rmod->inputbuf));
704
      cmdline_getinput(FP_SEG(rmod->inputbuf), FP_OFF(rmod->inputbuf));
705
      /* replace \r by a zero terminator */
705
      /* replace \r by a zero terminator */