forked from FDOS/freecom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath.c
46 lines (39 loc) · 1 KB
/
path.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* $Id$
* PATH.C - path command.
*
* Comments:
*
* 17 Jul 1998 (John P Price)
* Seperated commands into individual files.
*
* 27-Jul-1998 (John P Price <[email protected]>)
* - added config.h include
*
* 12-Aug-1998 ska
* - added: SUPPL environment handling
* currently "PATH=" will delete the environment variable PATH;
* if an empty one shall be created, replace chgEnv1() by chgEnv()
*/
#include "../config.h"
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../include/cmdline.h"
#include "../include/command.h"
#include "../include/context.h"
#include "../strings.h"
#define PATHVAR "PATH"
int cmd_path(char *param)
{ char *p;
/* >>PATH ;<< must remove the string entirely */
if(!param || (!*(p = ltrimcl(param)) && !strchr(param, ';'))) {
p = getEnv(PATHVAR);
displayString(p? TEXT_MSG_PATH: TEXT_MSG_PATH_NONE, p);
free(p);
return 0;
}
rtrimcl(p); /* remove trailing spaces */
return chgEnvRemove(PATHVAR, p);
}