Opened 8 years ago

Last modified 2 years ago

#36682 new defect

ksh93; typeset does not localize shell variable inside function

Reported by: ruttenberg@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: ryandesign (Ryan Schmidt)
Port: ksh93

Description

When a shell variable is "typeset" inside a function, changing the value inside the function should not affect the value of the variable outside of the function. This feature works properly in Solaris.

Attachments (2)

test (398 bytes) - added by ajdudman 5 years ago.
test.out (490 bytes) - added by ajdudman 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 years ago by ruttenberg@…

Cc: ruttenberg@… added

Cc Me!

comment:2 Changed 8 years ago by ryandesign (Ryan Schmidt)

Cc: ryandesign@… added; ruttenberg@… removed

I am not sure what to do about this, other than try to update ksh93 to a newer version, but of the newer versions I tried, I couldn't get them to build. What version is working for you on Solaris?

Changed 5 years ago by ajdudman

Attachment: test added

Changed 5 years ago by ajdudman

Attachment: test.out added

comment:3 Changed 5 years ago by ajdudman

This works properly for me. Maybe there is confusion between "function f" and "g()" style functions. The former has locally-scoped variables with the typeset builtin, (unless invoked with the . special builtin). The latter has shared variables. Or maybe it's expecting ksh to behave similarly to bash. Read ksh(1) man page below the "Functions." heading. Bash compatibility is under development, but may be tried by invoking ksh by the linked name "bash" or by "ksh -o bash". A test script and its output are attached.

Last edited 5 years ago by ajdudman (previous) (diff)

comment:4 Changed 2 years ago by ryandesign (Ryan Schmidt)

I've updated the ksh93 port to the latest version as of today, 20181007. Please try installing this version. If it still has the problem, please report it to the ksh developers.

Note: See TracTickets for help on using tickets.