[unix-pc.general] SUMMARY: pushd/popd ksh functions for the unix pc.

afc@shibaya.lonestar.org (Augustine Cano) (01/08/91)

First of all, many thanks to all those who responded to my original posting,
either in a followup or by e-mail; especially to those that sent or posted
code.

I now have 6 versions of pushd/popd and some auxiliary functions, including
the one I typed in that doesn't work.  Surprisingly the only differences
between my non-working version and another from the same source are minor
typographical differences (to fit the page layout of the book? NOT typos,
I checked more than once, very carefully) and function "to_tilde" which
is inline in the working version.

Before I received any code, I saw Thad's posting about the newer KSH from
the STORE, so the first thing I did was to upgrade.  Per the instructions,
which said to add "> $HISTFILE" to truncate the history file on login,
I added /etc/localprofile  (instead of adding that line to /etc/profile.)
This should not make any difference since /etc/localprofile is run from
/etc/profile, as shown below:

...
if [ -x /etc/localprofile ]
then
	. /etc/localprofile
fi
...

These are /etc/profile and /etc/localprofile:

-rw-r--r--  1 root    sys        3817 Nov 25 14:28 /etc/profile 
-rwxr-xr-x  1 root    sys          51 Dec 30 20:21 /etc/localprofile*

And this is /etc/localprofile:

# /etc/localprofile
# created by afc@shibaya.lonestar.org

> $HISTFILE

The problem is that the history file is not truncated at login time.  The
actual history file has these permissions: (just like ksh created it)

-rw-------  1 afc     users        52 Jan  7 22:17 /u/afc/.ksh.hist 

BTW, just typing ". /etc/localprofile" at the prompt has the
expected result.  What am I missing?

Back to pushd/popd:  Since I upgraded to the newer ksh before I tried any
of the code sent, I can't confirm that any of it works on the old version.
However, at least one sender said that his/her version works with V1.2.

As expected, most versions do the same thing.  Everything  I was sent works.
Here's a quick rundown: (in no particular order)

version #1: From: darren@bacchus.BACCHUS.ORG (Darren Friedlein)

The most compact of the bunch.  A grand total of 16 lines!  Including dirs,
pushd and popd.

I'm tempted to just include them below, but then this is not supposed to be
a source distribution.  If there is interest, I can forward everything I
received to Lenny for archiving at OSU.  How about starting a collection of
neat ksh functions?

version #2:  From: jwalz@rsg1.er.usgs.gov (Janet Walz)

According to her: "I grabbed these off the net a long time ago, and made
a couple minor tweaks (probably the sed lines that have similar-looking
things commented out)."

The original author of these is Ray Lubinsky, rwl@uvacs.cs.virginia.edu

This package contains pushd, popd, chdir (cd is aliased to chdir), dirs
and roll (this one is unique to this package, it does the obvious: roll
the stack).

version #3: From: quest!ssb@cs.umn.edu (Scott Sheldon Bertilson)

This package was written by Fletcher Mattox, sally!fletcher and claims to
emulate the csh dirs/pushd/popd exactly.  Some internal details are
different.

version #4: From: "Kris A. Kugel" <uunet!tsdiag.ocpt.ccur.com!hico2!kak>

This one came indirectly from none other than...  David Korn!  Very similar
to the one in the book, before the typesetters got to it, I suppose.

version #5: From: bruce@balilly.UUCP (Bruce Lilly)

If I recall correctly, this set was posted.  This is what Bruce said:

# In addition to Thad's comments, I can offer the following which ``sort
# of'' work (seems to be a minor problem after su'ing).  These are the
# ``dirs'', ``cd'', and ``mcd'' functions described in the same section as
# ``pushd'' and ``popd''.  The push and pop stuff is in-line.  I hope this
# helps.  I've also included a function ``su'' which allows one to run a
# shell as another user in a new window (using windy) -- with this, I only
# run a single login window, as I can then run a new window (e.g. as root)
# to do other things.


Well, here you have it, folks!  Any interest in having a sub-archive of
ksh functions?

Unrelated query:  is some major unix-pc hub down lately?  I haven't received
any unix-pc news in a couple of days.  Other groups are just fine.


-- 
Augustine Cano		INTERNET: afc@shibaya.lonestar.org
			UUCP:     ...!{ernest,egsner}!shibaya!afc