From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] pwd(1) In-Reply-To: Your message of "Sat, 01 Nov 2003 16:09:35 +0200." <1a0d27c99e832da94f5826a04e2c8e42@proxima.alt.za> From: "Russ Cox" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <55273.1067697286.1@t40.swtch.com> Message-Id: Date: Sat, 1 Nov 2003 09:34:46 -0500 Topicbox-Message-UUID: 7bace414-eacc-11e9-9e20-41e7f4b1d025 > Does it really return the value of the pathname which it failed to > retrieve when it fails to retrieve it? > > if(getwd(pathname, sizeof(pathname)) == 0) { > print("pwd: %r\n"); > exits(pathname); > } > > I hope I'm looking at old code. Did somebody forget to put quotes > around the exits() argument? You're looking at half-old code. The truly old code says: g% cat /n/bootes/sys/src/cmd/pwd.c #include #include /* * Print working (current) directory */ void main(int argc, char *argv[]) { char pathname[512]; USED(argc, argv); if(getwd(pathname, sizeof(pathname)) == 0) { print("pwd: %s\n", pathname); exits(pathname); } print("%s\n", pathname); exits(0); } g% which is the way getwd worked before 9P2000. I changed the current pwd just to exits("getwd") when getwd fails (after printing %r). Russ