[mod.computers.vax] Custom SET DEFAULT and directory stack manager...

aks@ACC.ARPA.UUCP (02/28/87)

Howdy, Folks!  I thought I'd contribute my two cents worth to the recent
submissions on custom SET DEFAULTS and directory managers.

I have five command procedures which I use to keep track of the various
directories in which I'm working and to avoid having to type their path names
more than once (don't you hate typing those long VMS directory names!).
Although, they're probably a re-invention of someone's wheel out there, I
haven't yet seen an article describing any vehicle's using such wheels.

CD	does SET DEFAULT with wildcard support, elipses (...), and non- or
	bad-directory detection.  Returns $STATUS on success or failure, so
	other command procedures can intelligently use it.  For example,
	suppose I wanted to change to a directory under the PROJECT root,
	starting with the ISO directory, and ending with the TEST subdirectory,
	and I-don't-care-to-name all the subdirectories between.  Simple.  Do:

	$ CD PROJECT:[ISO...TEST]

	Of course, CD expands (using F$SEARCH) the pathname so that the actual,
	real path name becomes the current directory.  If more than one
	subdirectory can be found, then it's a "first-come first-served".

PUSHDIR	from UNIX csh(1) "pushd" command.  This procedure accepts either a VMS
	directory pathname, or a number.  If a pathname is given, the current
	default is "pushed" onto a directory stack, and the given name is set
	as the current directory, using CD.  This allows wildcards, elipses,
	and bad-directory detection to work here as well.  Also, the new
	directory stack is printed if the procedure level is 2 (that is,
	entered from the command level interactively).  As an example, suppose
	that we've just entered the CD command given above, and now want to
	"push" to another peer directory, called "SRC.MAIN".  Simple.  Do:

	$ PUSHDIR [-.SRC.MAIN]
	#0  PROJECT:[ISO.REV3_1.CLIP.SRC.MAIN]
	#1  PROJECT:[ISO.REV3_1.CLIP.TEST]

	The two lines following the command are printed by the PUSHDIR command.

	If a number is given, then that number directory, defaulting to 1, is
	"popped" to the top of the stack, resulting in its become the current
	default.  The previous default directory is "pushed" under it.

POPDIR	from UNIX csh(1) "popd" command.  This procedure accepts a number,
	defaulting to 0, which pops that numbered directory off the stack and
	discarded.  The new #0 directory (if different) becomes the new current
	default directory.  The stack is also printed if the procedure level is
	2.  Continuing the previous example, by pushing another directory and
	then popping one:

	$ PUSHDIR [-.TEXT]
	#0  PROJECT:[ISO.REV3_1.CLIP.SRC.TEXT]
	#1  PROJECT:[ISO.REV3_1.CLIP.SRC.MAIN]
	#2  PROJECT:[ISO.REV3_1.CLIP.TEST]
	$ PUSHDIR 2
	#0  PROJECT:[ISO.REV3_1.CLIP.TEST]
	#1  PROJECT:[ISO.REV3_1.CLIP.SRC.TEXT]
	#2  PROJECT:[ISO.REV3_1.CLIP.SRC.MAIN]
	$ POPDIR 1
	#0  PROJECT:[ISO.REV3_1.CLIP.TEST]
	#2  PROJECT:[ISO.REV3_1.CLIP.SRC.MAIN]

DIRSTACK from UNIX csh(1) "dirs" command.  In the examples above, the output
	was produced by DIRSTACK.

DIRCLEAN from my brain.  Resets the directory stack.  The current default
	becomes the only directory on the stack.

The files are two much (and so is this mailing it turns out) to send out as an
initial mailing.  But, if anyone is interested in the sources (DCL command
files), I'll be glad to send them.  Just send me mail.

Thanks for your patience.

Alan Stebbens (aks@acc.ARPA)

------