On Tue, 18 Aug 2009, Jan Ingvoldstad wrote:
On Tue, Aug 18, 2009 at 2:33 PM, David Green <david.gr...@telus.net> wrote:
Huh. Thank you, I did not know that. It makes "sense" (in that I
understand what's going on now that I see it, and indeed it seems almost
obvious), but I certainly couldn't call it "expected" because I didn't. And
I can guarantee I'm not the only one; in fact, I have no qualms about
classifying that as a bug.
You think it's a bug that PWD="/etc" doesn't change your working directory
to /etc in bash?
Please tell me you're joking.
..but Perl is more magic than bash :). Seriously, I can see both
sides of the argument, and I'm leaning towards the $*CWD = chdir idea (as an
option if people want to use it), but I realise that a lot of people are
leaning the other way. So I'll argue for it, but don't care if I lose :).
The environment variables are generally just descriptive variables. If you
mess with them, they may no longer have bearing on reality. That is also
expected behaviour; if you shoot yourself in the foot, you may get hurt.
It can also be said to be expected behaviour because that's the way it has
been behaving for maybe as long as environment variables have been in
existence in Unix systems.
Here's another example of something that, if I understand you correctly, you
find as unexpected behaviour:
j...@krakas ~ >USER=root
j...@krakas ~ >echo $USER
root
# Am i root now?
j...@krakas ~ >whoami
jani
# I'm not root.
While there have been programs assuming that %ENV{USER} indicates who the
current user is, and adjusting their behaviour based on that, such behaviour
has generally been classified as a security vulnerability, and rightly so.
I think David Green's argument would be that, in something as magic as
Perl, doing USER=root should call setuid(), and chuck an error when it fails.
And note that Perl 5 allows you to do exactly this, if I understand the
documentation for "EFFECTIVE_USER_ID" in the perlvar manpage correctly.
So, if P5 does it for some global (note: global != environment)
variables, then why not do it for some in P6? Note that no-one's stopping you
from doing this:
chdir("/usr/bin");
say "%*ENV<PWD> -- $*CWD\n"
$*CWD = "/usr/lib";
%*ENV<PWD> = "/foo/notadirectory";
say "%*ENV<PWD> -- $*CWD\n"
...which would print:
/usr/bin/ -- /usr/bin
/foo/notadirectory -- /usr/lib
So, you can still set %*ENV<PWD> how you want, but $*CWD ties to
getcwd and chdir the way some other people want. Yes?
:)
---------------------------------------------------------------------
| 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-----