]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/pwd.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / pwd.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include <stdio.h>
9 #include <strings.h>
10
11 extern FILE *popen ();
12
13 char *
14 pwd()
15 {
16 register FILE *pp;
17 static char curpath[128];
18
19 if((pp = popen("pwd", "r")) == NULL ||
20 fgets(curpath, sizeof curpath, pp) == NULL ||
21 pclose(pp) != 0) {
22 fprintf(stderr, "Can't find current directory!\n");
23 done(1);
24 }
25 *rindex(curpath, '\n') = 0; /* Zap the lf */
26 return curpath;
27 }