2 * PATH.C - path internal command.
7 * 17 Jul 1998 (John P Price)
8 * Separated commands into individual files.
10 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
11 * added config.h include
13 * 09-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
14 * Added help text ("/?").
16 * 18-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
19 * 18-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
22 * 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
23 * Fixed Win32 environment handling.
28 #ifdef INCLUDE_CMD_PATH
38 /* size of environment variable buffer */
39 #define ENV_BUFFER_SIZE 1024
42 INT cmd_path (LPTSTR cmd, LPTSTR param)
44 if (!_tcsncmp (param, _T("/?"), 2))
46 ConOutPuts (_T("Displays or sets a search path for executable files.\n\n"
47 "PATH [[drive:]path[;...]]\nPATH ;\n\n"
48 "Type PATH ; to clear all search-path settings and direct the command shell\n"
49 "to search only in the current directory.\n"
50 "Type PATH without parameters to display the current path.\n"));
54 /* if param is empty, display the PATH environment variable */
55 if (!param || !*param)
60 pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
61 dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
64 ConErrPrintf (_T("CMD: Not in environment \"PATH\"\n"));
67 else if (dwBuffer > ENV_BUFFER_SIZE)
69 pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
70 GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
73 ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
79 /* skip leading '=' */
80 if (*param == _T('='))
83 /* set PATH environment variable */
84 if (!SetEnvironmentVariable (_T("PATH"), param))