penpen wrote:My interpretation of what Magoo has written differs a lot!
I think he said(in other words): The "for" command needs the dynamic variable in order to work correctly.
This is not a different interpretation. We are trying to say the same thing. But I like your way of putting it.
penpen wrote:And in addition i think Magoo predicts, that "c:\test" is returned in your above example, although the static environment variable __CD__ is set to "z:\bogus\".After using "PUSHD someconvenientdir" someconvenientdir is the current directory.Magoo wrote:SET __CD__ to whatever you like, the current dirname will STILL be echoed.
PUSHD someconvenientdir before that FOR and someconvenientdir will be echoed.
SET CD=bogus and the current directory will be echoed (...)
=> Prediction: The current (real) directory is returned no matter of the value in the static environment variable:Magoo wrote:~f will use %__CD__% NOT from the environment where the directoryname isn't explicit
But I don't think Magoo was aware that %__CD__% behaves differently on XP, as evidenced by MC ND's answer and foxidrive's comment. On XP, ECHO %__CD__% displays the static environment variable, if one is defined. On Win 7 and Win 8 it always displays the actual current directory, even if a static user value is defined.
penpen wrote:Btw: Using your above example, Windows XP returns "C:\test".
Excellent! I believe this proves that FOR must not be using the dynamic variable to retrieve the current directory. If you can add one more line to the end of the test: echo %__CD__%, then all the evidence will be in one place.
Based on what you report, %%~fA returns C:\test on XP.
Based on MC ND's answer and foxidrive's comment, echo %__CD__% should return z:\bogus\test on XP.
In my mind, this would disprove Magoo's theory that FOR needs the __CD__ dynamic variable to work properly.
Dave Benham