Subversion Repositories SvarDOS

Rev

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

Rev 462 Rev 533
Line 26... Line 26...
26
 * path
26
 * path
27
 *
27
 *
28
 * Displays or sets a search path for executable files.
28
 * Displays or sets a search path for executable files.
29
 */
29
 */
30
 
30
 
31
static int cmd_path(struct cmd_funcparam *p) {
31
static enum cmd_result cmd_path(struct cmd_funcparam *p) {
32
  char *buff = p->BUFFER;
32
  char *buff = p->BUFFER;
33
 
33
 
34
  /* help screen (/?) */
34
  /* help screen (/?) */
35
  if (cmd_ishlp(p)) {
35
  if (cmd_ishlp(p)) {
36
    output("Displays or sets a search path for executable files.\r\n"
36
    output("Displays or sets a search path for executable files.\r\n"
Line 40... Line 40...
40
           "\r\n"
40
           "\r\n"
41
           "Type PATH ; to clear all search-path settings and direct DOS to search\r\n"
41
           "Type PATH ; to clear all search-path settings and direct DOS to search\r\n"
42
           "only in the current directory.\r\n"
42
           "only in the current directory.\r\n"
43
           "\r\n"
43
           "\r\n"
44
           "Type PATH without parameters to display the current path.\r\n");
44
           "Type PATH without parameters to display the current path.\r\n");
45
    return(-1);
45
    return(CMD_OK);
46
  }
46
  }
47
 
47
 
48
  /* no parameter - display current path */
48
  /* no parameter - display current path */
49
  if (p->argc == 0) {
49
  if (p->argc == 0) {
50
    char far *curpath = env_lookup(p->env_seg, "PATH");
50
    char far *curpath = env_lookup(p->env_seg, "PATH");
Line 56... Line 56...
56
        buff[i] = curpath[i];
56
        buff[i] = curpath[i];
57
        if (buff[i] == 0) break;
57
        if (buff[i] == 0) break;
58
      }
58
      }
59
      outputnl(buff);
59
      outputnl(buff);
60
    }
60
    }
61
    return(-1);
61
    return(CMD_FAIL);
62
  }
62
  }
63
 
63
 
64
  /* more than 1 parameter */
64
  /* more than 1 parameter */
65
  if (p->argc > 1) {
65
  if (p->argc > 1) {
66
    outputnl("Too many parameters");
66
    outputnl("Too many parameters");
67
    return(-1);
67
    return(CMD_FAIL);
68
  }
68
  }
69
 
69
 
70
  /* IF HERE: THERE IS EXACTLY 1 ARGUMENT (argc == 1) */
70
  /* IF HERE: THERE IS EXACTLY 1 ARGUMENT (argc == 1) */
71
 
71
 
72
  /* reset the PATH string (PATH ;) */
72
  /* reset the PATH string (PATH ;) */
73
  if (imatch(p->argv[0], ";")) {
73
  if (imatch(p->argv[0], ";")) {
74
    env_dropvar(p->env_seg, "PATH");
74
    env_dropvar(p->env_seg, "PATH");
75
    return(-1);
75
    return(CMD_OK);
76
  }
76
  }
77
 
77
 
78
  /* otherwise set PATH to whatever is passed on command-line */
78
  /* otherwise set PATH to whatever is passed on command-line */
79
  {
79
  {
80
    unsigned short i;
80
    unsigned short i;
Line 84... Line 84...
84
      if (buff[i + 5] == 0) break;
84
      if (buff[i + 5] == 0) break;
85
    }
85
    }
86
    env_setvar(p->env_seg, buff);
86
    env_setvar(p->env_seg, buff);
87
  }
87
  }
88
 
88
 
89
  return(-1);
89
  return(CMD_OK);
90
}
90
}