Thanks....
Mark Weaver
mwe...@licd.sps.mot.com
mw> I was hoping that someone might have the source code for the
mw> Unix 'cd' command.
What does this have to do with Standard C? I must have missed that
section in the standard...
Anyway, there is no "cd command" in UNIX. cd is a shell builtin command
(it *has* to be, if you think about it).
So, just find the source code to your shell and look in there. You'll
need that source code anyway if you want to rebuild the shell with a
modified version of cd.
I suggest a more fruitful (and portable) approach might be to check out
csh's aliasing function and see if you can't overlay whatever features
you want onto cd that way. Alternatively, get a better shell than csh
like bash or ksh (but I like bash better personally) where you can
define real functions; csh's aliases are soooo gross. IMHO. :)
--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@wellfleet.com> Network Management Development
Senior Software Engineer Bay Networks, Inc.
-------------------------------------------------------------------------------
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
Check out Linux. A fairly full Unix implementation and source
for the whole thing is available.
Cheers,
Harry
If you're just looking for the way to change the current working directory
in a program, look at the chdir system call.
% man 2 chdir
NAME
chdir - change current working directory
SYNOPSIS
int chdir(path)
char *path;
int fchdir(fd)
int fd;
DESCRIPTION
chdir() and fchdir() make the directory specified by path or
fd the current working directory. Subsequent references to
pathnames not starting with `/' are relative to the new
current working directory.
In order for a directory to become the current directory, a
process must have execute (search) access to the directory.
--
+------------------------------------------------------------------------+
| Pete Kockritz Pete.K...@ti.com |
| Texas Instruments pet...@aol.com |
| McKinney, TX Voice: 214-952-4077 |
| This space for rent. |
+------------------------------------------------------------------------+
Unfortunately, this won't really help the original poster. The cd command
is necessarily built into the shell on any Unixish system. And the C Shell
is *not* freely available, because it uses some Unix source code. Moreover,
there is (as far as I know) no free clone of it, because it's such an awful
ad-hoc mess that merely sorting out the specs well enough to permit cloning
would be a major chore.
--
There is a difference between | Henry Spencer
cynicism and skepticism. | he...@zoo.toronto.edu