On Tue, 18 Aug 2009, Mark J. Reed wrote:
On Tue, Aug 18, 2009 at 11:04 AM, David Green<david.gr...@telus.net> wrote:
On 2009-Aug-18, at 2:29 am, Carlin Bingham wrote:
chdir provides functionality that would be quite convoluted to mimic
through manually setting $*CWD, such as changing to a relative
directory.
Maybe setting $*CWD just calls chdir() under the hood? Same implementation,
brand new shiny Perl-style interface!
If $*CWD is really a Path object and not a Str, then it should be easy
to use mutator methods to change to a relative directory and do other
chdir()ish things. Say, concatenation works in terms of path
components, for instance:
$*CWD ~= $subdir; # chdir($subdir)
With a method for getting the parent:
given $*CWD { $_ = $_.up ~ $sibling } # chdir("../$sibling")
and so on. My favorite kshism is "cd old new" which does a
search/replace on the current working directory; the bash equivalent
"cd ${PWD/old/new}" which is not quite as handy. $*CWD could make
that simple, too.
It's not in the revised spec, but I think that, even though
we've revived chdir, we should still have it so that changing $*CWD will do a
chdir under the hood.
My intent is that Path should be able to act as a string, at least to
a certain extent, and should also be able to act as an array of Str. So
Mark's second example could be done as:
pop $*CWD; push $*CWD $sibling
HTH,
---------------------------------------------------------------------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayl...@wayland.id.au | I am |
---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----