Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

ksh93: Changes to functions within subshells are ignored #73

@McDutchie

Description

@McDutchie

Function definitions within non-forked subshells (including command substitutions) are silently ignored if a function by the same name exists in the main shell, so the wrong code is executed. unset -f is also silently ignored. Test script:

foo() { echo WRONG; }
(foo() { echo ok; } && foo && unset -f foo && foo)

Output:

WRONG
WRONG

Forcing the subshell to be forked (by making it a background job, or by including a redirection within a command substitution) is an effective workaround.

Silently executing the wrong code under any circumstances is a bad bug, but it seems to have been in ksh93 since 1993...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions