From: Alan Curry on
In article <63f539f4-4518-4420-9dad-d71e5fad7493(a)r24g2000yqd.googlegroups.com>,
Douglas Alan <darkwater42(a)gmail.com> wrote:
>On Jan 6, 9:47�pm, pac...(a)kosh.dhis.org (Alan Curry) wrote:
>
>> Why don't you show us what you meant with an actual example, in which you
>> have set -P and it still doesn't do what you want?
>
>I already did, when I wrote previously:

But what you wrote previously when I asked for a repeatable experiment did
not have set -P in it. If you intended for the set -P to be done first, you
should have included it as part of the instructions.

I tried that experiment exactly as you said, and the behavior you described
occurred. Then I did set -P and it behaved differently. Does it not do that
for you?

From: Douglas Alan on
On Jan 6, 10:24 pm, pac...(a)kosh.dhis.org (Alan Curry) wrote:

> I tried that experiment exactly as you said, and the behavior you described
> occurred. Then I did set -P and it behaved differently. Does it not do that
> for you?

Hmmm, actually now it does work for me!

When I originally posted about the problem last night, I must have
somehow gotten bash into a confused state, as "set -P" fixed
everything then *except* for filename completion. I found this
exception to be annoying. But now, though, once I do "set -P",
everything is working fine.

Well, thanks!
|>ouglas
From: Douglas Alan on
On Jan 7, 4:41 am, jellybean stonerfish <stonerf...(a)geocities.com>
wrote:

> First I 'cd' directly into the '/home/js/multimedia/pics/' directory,
> Then use 'cd ..' and end up in '/home/js/multimedia' as I should.
>
> $cd /home/js/multimedia/pics/
> $pwd
> /home/js/multimedia/pics
> $cd ..
> $pwd
> /home/js/multimedia
>
> Now, if I us the symlink '/home/js/pictures' I end up in the same
> directory, '/home/js/multimedia/pics', but it acts like a different
> place. 'pwd' returns '/home/js/pictures' and 'cd ..' leaves me in
> '/home/js'  And you don't like this behavior?

Precisely so, but as it turns out "set -P" fixes everything to work
the way I want it to. (I.e., as every other shell behaves.) At the
time I made my initial query, "set -P" had fixed everything for me
*except* for filename completion, and I couldn't figure out how to fix
filename completion. But I guess I had been fiddling with bash too
much and somehow confused it. With a fresh bash, "set -P" does the job
on everything including filename completion. (Or at least I haven't
yet noticed something that "set -P" doesn't quite fix.)

|>ouglas
From: Stephane CHAZELAS on
2010-01-7, 07:12(-08), Douglas Alan:
> On Jan 7, 4:41�am, jellybean stonerfish <stonerf...(a)geocities.com>
> wrote:
>
>> First I 'cd' directly into the '/home/js/multimedia/pics/' directory,
>> Then use 'cd ..' and end up in '/home/js/multimedia' as I should.
>>
>> $cd /home/js/multimedia/pics/
>> $pwd
>> /home/js/multimedia/pics
>> $cd ..
>> $pwd
>> /home/js/multimedia
>>
>> Now, if I us the symlink '/home/js/pictures' I end up in the same
>> directory, '/home/js/multimedia/pics', but it acts like a different
>> place. 'pwd' returns '/home/js/pictures' and 'cd ..' leaves me in
>> '/home/js' �And you don't like this behavior?
>
> Precisely so, but as it turns out "set -P" fixes everything to work
> the way I want it to. (I.e., as every other shell behaves.)
[...]

Although I agree with you that this behavior is annoying, it is
a behavior that has been found since the 80s, that was
introduced by the Korn shell, and even standardized by
POSIX.

So all the POSIX shells (bash, ksh, pdksh, posh, mksh, zsh,
recent ash...) behave like that and bash is not the one to
blame here.

That's the reason why in POSIX scripts, you have to write:

cd -P -- "$dir"
instead of
cd -- "$dir"

to get the same behavior as in other programming languages (and
a consistent behavior).

--
St�phane
From: Douglas Alan on
On Jan 7, 12:39 pm, Stephane CHAZELAS <stephane_chaze...(a)yahoo.fr>
wrote:

> So all the POSIX shells (bash, ksh, pdksh, posh, mksh, zsh,
> recent ash...) behave like that and bash is not the one to
> blame here.
>
> That's the reason why in POSIX scripts, you have to write:
>
> cd -P -- "$dir"
> instead of
> cd -- "$dir"
>
> to get the same behavior as in other programming languages (and
> a consistent behavior).

Hmmm, I didn't try cd in these other shells previously, but I did try
filename completion in ksh and zsh (not to mention tcsh, which I use
every day), and they do filename completion according to the physical
directory structure. (At least on my Mac.)

I just tried cd in ksh and zsh, and you're right. Which means that ksh
and zsh are just plain broken because they don't behave consistently.

And the posix folks are less that brilliant, if you ask me, for
requiring behavior that is inconsistent with normal Unix semantics and
with "real" programming languages.

Not that I have anything against having a way to navigate your
"logical directory structure", but they shouldn't have overloaded that
by default onto a notation that was already well defined.

And while they were at it, they should have required a "back"
function, like web browsers have. So that you might do "cd --back" to
retrace your cd steps.

|>ouglas