On Tue, Aug 18, 2009 at 10:37 AM, Jan Ingvoldstad<frett...@gmail.com> wrote:
>> It's not that unreasonable.
>
> I disagree, and I think I've explained why, and perhaps we won't get much
> further.

I'm not claiming that it's a good idea for bash to adopt this
behavior, only that it's a reasonable expectation tohave upon
encountering the read behavior of $PWD.
Its not unlike, say, applying an UPDATE to a view in an RDBMS: it
seems like it should work.  It might not, for various reasons, but
it's not an unreasonable expectation. And in many versions of SQL it
does work for the simpler view/table relationships.

>> But USER isn't even a shell-maintained variable.
>
> I'm not sure what you mean by a "shell-maintained variable".

I mean, it's not a parameter that is ever set by the shell.  Unlike
PWD, RANDOM, LINENO, PPID, etc. which are set by the shell.

> As for $UID being read-only, that's a bashism. There's nothing inherent
> about $UID that makes it read-only.

Huh?  I thought UID was a bashism.  In my copies of ksh, it's not even
set - AT&T ksh93 (version M 1993-12-28 s+ under UWIN, Version JM 93t+
2009-05-01
 on Linux) and pdksh 5.2.14. .  If it's POSIX, it must be a a
relatively recent addition.

> In a POSIX shell, you get this:
>
> $ ksh --version
>  version         sh (AT&T Research) 1993-12-28 s+
> $ echo $UID $USER
> 501 jani

Not here.

> bash in POSIX mode agrees:

What version of bash?  bash-3.2:

$ bash --posix
bash-3.2$ echo $UID
1024
bash-3.2$ UID=500
bash: UID: readonly variable

Did you maybe export UID,  so it's being inherited by these subshells?

> Even Perl 5 lets me change it:

OK, you clearly exported UID.  It's not exported by default, so
$ENV{UID} in Perl should be unset.   Try your experiments without
exporting UID.

In any case, %ENV isn't readonly in Perl. But neither are the contents
of %ENV managed by Perl - just inherited from the parent process.
-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to