Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem redeclaring path variable (ksh incompatibility)



Hi Bart

Thanks for your reply.

Try running your test script with ARGV0=sh in the environment and note
the difference in behavior.

It didn't appear to make any difference. Are you sure this hides $path, or are you just suggesting this should be the normal way to invoke zsh any time I want it to conform closely to POSIX shell?

In any case, thanks for pointing out that feature. I discovered this difference when asking zsh to read my general POSIX/Korn shell .shrc, so it is clear I should enable any sh/ksh compliance features before doing so. I'll definitely investigate it some more.

} It turns out that neither "typeset path=" nor "typeset path=value" } create a local scalar, which doesn't meet my expectations. Strangely, } however, "typeset path" does.

No, it doesn't.  Nowhere in your test script is $path a scalar.

I had assumed it was since subsequent attempts to assign scalar (string) values to it succeed, and its global value is restored outside of the function.

So this works:
typeset path
path=
path="scalar"

But this doesn't:
typeset path=
path="scalar"

And neither does this:
typeset path=""
path="scalar"

zsh% func() { emulate ksh; typeset path ; path=scalar ; typeset path }
zsh% func
path=(scalar)

Assuming a -m flag to the final typeset, this certainly verifies what you said.

Thanks



Messages sorted by: Reverse Date, Date, Thread, Author