Discussion:
[ast-developers] [BUG] function definitions within subshells are ignored
Martijn Dekker
2015-06-07 20:28:16 UTC
Permalink
ksh93 does not respect function definitions within subshells; it ignores
a function definition within a subshell if a function by that name
already exists in the main shell. This applies both to regular subshells
and to command substitutions.

Test script:

#! /bin/ksh
fn() {
echo 'Version 1'
}
fn

echo $(
fn() {
echo 'Version 2'
}
fn
)

(
fn() {
echo 'Version 3'
}
fn
)

Actual output (confirmed for '1993-12-28 s+' and '93u+ 2012-08-01'):
Version 1
Version 1
Version 1

Interestingly, ksh93 version '93t+ 2010-03-05' produces different output:
Version 1
Version 1
Version 3

Expected output (produced by mksh, bash, zsh, yash, dash, ash):
Version 1
Version 2
Version 3

Thanks,

- Martijn

Loading...