Command 'cd' now switches to the home directory also for MS Windows.
A new command 'getcwd' just prints the current working directory without changing it.
This commit is contained in:
parent
9cc690c55c
commit
f07c73b6a5
|
|
@ -32,6 +32,8 @@ com_chdir(wordlist *wl)
|
|||
if (wl == NULL) {
|
||||
|
||||
s = getenv("HOME");
|
||||
if (!s)
|
||||
s = getenv("USERPROFILE");
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
if (s == NULL) {
|
||||
|
|
@ -65,3 +67,21 @@ com_chdir(wordlist *wl)
|
|||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* just print the current working directory */
|
||||
void
|
||||
com_getcwd(wordlist *wl)
|
||||
{
|
||||
NG_IGNORE(wl);
|
||||
#ifdef HAVE_GETCWD
|
||||
char *s;
|
||||
char localbuf[257];
|
||||
s = getcwd(localbuf, sizeof(localbuf));
|
||||
if (s)
|
||||
printf("Current directory: %s\n", s);
|
||||
else
|
||||
fprintf(cp_err, "Can't get current working directory.\n");
|
||||
#else
|
||||
fprintf(cp_err, "Error, function getcwd not available\n");
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@
|
|||
#include "ngspice/wordlist.h"
|
||||
|
||||
void com_chdir(wordlist *wl);
|
||||
void com_getcwd(wordlist *wl);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -511,6 +511,10 @@ struct comm spcp_coms[] = {
|
|||
{ 1, 0, 0, 0 }, E_DEFHMASK, 0, 1,
|
||||
NULL,
|
||||
"[directory] : Change working directory." } ,
|
||||
{ "getcwd", com_getcwd, FALSE, FALSE,
|
||||
{ 1, 0, 0, 0 }, E_DEFHMASK, 0, 1,
|
||||
NULL,
|
||||
"[directory] : Print current working directory." } ,
|
||||
{ "version", com_version, FALSE, FALSE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
|
|
@ -920,6 +924,10 @@ struct comm nutcp_coms[] = {
|
|||
{ 1, 0, 0, 0 }, E_DEFHMASK, 0, 1,
|
||||
NULL,
|
||||
"[directory] : Change working directory." } ,
|
||||
{ "getcwd", com_getcwd, FALSE, FALSE,
|
||||
{ 1, 0, 0, 0 }, E_DEFHMASK, 0, 1,
|
||||
NULL,
|
||||
"[directory] : Print current working directory." } ,
|
||||
{ "version", com_version, FALSE, FALSE,
|
||||
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS,
|
||||
NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue