From: Mike Engelhardt (engel@netcom.com)
Date: 03/10/93


From: engel@netcom.com (Mike Engelhardt)
Subject: Re: 'pwd' in tcsh and csh
Date: 10 Mar 1993 18:58:23 GMT


> > ...But when I switched to 'tcsh' or 'csh', I can't do a 'pwd'.
> > What's wrong?...

> Put the following line in ur .tcshr or .cshrc file...
> alias pwd 'echo "$cwd"'

Echoing $cwd is certainly the best advice for interactive use. But
it's probably also good to have a /usr/bin/pwd or /bin/pwd so that
shell scripts that require it will run without modification. Also,
I like to have a pwd command that returns the absolute current path
without symbolic links. The standard approach we've seen in
Linux/SLS is to have an executable bash script with the contents:

#!/bin/bash
pwd

If you want one that does not require the presence of any particular
shell, as I prefer, then the following program is maybe a more
'standard' way of doing it:

/* ---- pwd.c ----
 *
 * To build: cc -O -N -s pwd.c -o pwd
 */

#include <stdio.h>
#include <unistd.h>

main()
{
   char buffer[4096]; /* I think 4K is correct the limit for Linux */

   printf("%s\n", getwd(buffer));
   return(0);
}