9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pwd(1)
Date: Sat,  1 Nov 2003 09:34:46 -0500	[thread overview]
Message-ID: <E1AFwq4-000ENX-TO@t40.swtch.com> (raw)
In-Reply-To: Your message of "Sat, 01 Nov 2003 16:09:35 +0200." <1a0d27c99e832da94f5826a04e2c8e42@proxima.alt.za>

> 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 <u.h>
 #include <libc.h>
/*
 * 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


  reply	other threads:[~2003-11-01 14:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-01 14:09 lucio
2003-11-01 14:34 ` Russ Cox [this message]
2003-11-01 14:57   ` Lucio De Re
2003-11-01 15:04     ` Russ Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1AFwq4-000ENX-TO@t40.swtch.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).