[comp.sys.amiga] "Pushing" and "popping" current directory

wfh58@leah.Albany.Edu (William F. Hammond) (01/04/90)

Several weeks ago in response to a query about "pushing" and "popping"
current directories on the Amiga, as in UNIX, with appropriate
aliases, I suggested some possibilities with the ARP shell (which is
more powerful than the WorkBench 1.3 shell and is freely available).

What I suggested did not actually provide "true" popping, and somebody
else suggested a better alternative by scripting.  The problem that I
had previously had with "true" popping via aliases turns out to be
tied up with issues of residency rather than with the shell itself.

Here is what I suggest: (commands are assumed to be ARP; '\' the
escape)

ares c:cd as cd force
ares c:cd as cd1 force
alias eq  echo "\x22" noline
alias sd  cd \$(eq)\$(set pcd "\$(cd1)")[]\$(eq)
alias pop  cd "\$(set ncd "\$pcd")\$(set pcd "\$(cd1)")\$ncd"

[ARP "cd" is of size 580 bytes.  So making it resident under two
different names is not an enormous strain on the system. If "cd" is
not resident, then the "cd1" maneuver is not necessary; that is,
replace "cd1" above with "cd".]

The "eq" maneuver in "sd" is necessary, because the command line
substitution delimiters "[]" will be taken literally if enclosed in
quotes.

(Of course, easier alternatives are available with other shells.  For
example, "WShell" (commercial -- W. Hawes, Maynard, MA) has a built-in
"pop".)
------------------------------------------------------------------------
William F. Hammond                   Dept. of Mathematics & Statistics
518-442-4625                         SUNYA, Albany, NY 12222
wfh58@leah.albany.edu                wfh58@albnyvms.bitnet
-------------------------------------------------------------------------