diff options
author | Sadrul Habib Chowdhury <sadrul@users.sourceforge.net> | 2010-03-23 23:00:26 -0400 |
---|---|---|
committer | Sadrul Habib Chowdhury <sadrul@users.sourceforge.net> | 2010-03-23 23:05:02 -0400 |
commit | 9c2fb084492ec102da749e75e5514114eee4bf01 (patch) | |
tree | 8cda325dbe5fb033ada1140ec49e165785e27a50 /src/process.c | |
parent | f7adfae856bb83107024559bf3b167bc4b9a42df (diff) | |
download | screen-9c2fb084492ec102da749e75e5514114eee4bf01.tar.gz |
Expand $PWD to screen's current working directory.
Expanding $PWD to expand to the correct current working directory
can be useful to figure out, for example, where log files are
created, and other purposes.
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/process.c b/src/process.c index cb90802..68f3db9 100644 --- a/src/process.c +++ b/src/process.c @@ -4627,7 +4627,7 @@ int bufl, *argl; else if (delim != '\'' && *p == '$' && (p[1] == '{' || p[1] == ':' || (p[1] >= 'a' && p[1] <= 'z') || (p[1] >= 'A' && p[1] <= 'Z') || (p[1] >= '0' && p[1] <= '9') || p[1] == '_')) { - char *ps, *pe, op, *v, xbuf[11]; + char *ps, *pe, op, *v, xbuf[11], path[MAXPATHLEN]; int vl; ps = ++p; @@ -4671,6 +4671,13 @@ int bufl, *argl; sprintf(xbuf, "%d", display ? D_height : -1); else if (!strcmp(ps, "PID")) sprintf(xbuf, "%d", getpid()); + else if (!strcmp(ps, "PWD")) + { + if (getcwd(path, sizeof(path) - 1) == 0) + v = "?"; + else + v = path; + } else if (!strcmp(ps, "STY")) { if ((v = strchr(SockName, '.'))) /* Skip the PID */ |