Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

'pwd' in tcsh and csh

598 views
Skip to first unread message

Kee Chua

unread,
Mar 9, 1993, 4:34:43 PM3/9/93
to

Hi people,
I noticed that when I used 'sh' shell, I have 'pwd' working. But when I
switched to 'tcsh' or 'csh', I can't do a 'pwd'. What's wrong? If 'pwd' is
embedded in the shell and if tcsh and csh doesn't have it, where can I get
one?

Thanks in advance,
Kee Chua

Yoonsik Cheon

unread,
Mar 9, 1993, 11:33:16 PM3/9/93
to

Put the following line in ur .tcshr or .cshrc file.....

alias pwd 'echo "$cwd"'

Yoonsik

--
Yoonsik Cheon, ch...@cs.iastate.edu

lio...@maple.circa.ufl.edu

unread,
Mar 9, 1993, 11:21:14 PM3/9/93
to

I noticed that too. I had to do an alias of:

alias pwd 'PWD'

or something like that.

Brian

Mike Engelhardt

unread,
Mar 10, 1993, 1:58:23 PM3/10/93
to
> > ...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);
}

Ralf Dreier

unread,
Mar 11, 1993, 2:14:21 AM3/11/93
to

I have written a small program pwd:

/*
* pwd for Linux
*
* Siegen, 29.01.93
*/
#include <stdio.h>

char *cwd, *getcwd();

main() {
if ((cwd = getcwd((char *)NULL, 256)) == NULL) {
perror ("pwd");
exit (1);
}
printf("%s\n", cwd);
}


--------------------------------------------------------------------------
Ralf Dreier | Universitaet-GH-Siegen
| Institut fuer
email dre...@fb5.uni-siegen.de | Wirtschaftsinformatik
Phone 49 271/740-3262 | Hoelderlinstr. 3
Fax 49 271/740-2310 | D-W-5900 Siegen, Germany

Joe Ammond

unread,
Mar 11, 1993, 10:54:06 AM3/11/93
to

Well, that works well, but what about shells that don't store the current
working directory in the environment (i.e. rc). The Berzerkeley 'pwd'
program from your nearest bsd-net2 site compiles out of the box (Not
surprising, since it's only about 20 lines).

On a related note, has anyone ported the net2 Bourne shell clone? Bash is
nice as an interactive shell, but as a quick scripting language it can be
kind of overkill.

ja. Mentally Contaminated, and *DAMN* proud of it.
--
Suicidal Cyko Joe Ammond amm...@gdls.com
Unix System Administrator Computer Sciences Corporation
"your will to speak clearly/exposed too much
unsung once to often/could not rub off" -Helmet

0 new messages