I know there are no active developers at this point, but here's one for
the archives in case there are active developers in the future.

The ${.sh.subshell} (subshell level) variable is broken:

case $(echo ${.sh.subshell} 1>&2
       echo ${.sh.subshell} 1>&2
       echo ${.sh.subshell}) in
1) echo ok ;;
esac

This should output '1' twice and then 'ok'. Instead it outputs '1' and
then '0'.

This means ${.sh.subshell} is reset after the first access, so only the
first access is correct.

Interestingly this all works fine on ancient ksh93, at least "Version M
1993-12-28 r" as installed on sdf-eu.org. But versions as of at least
2010 and later all have this problem.

Since ksh93 uniquely does subshells without forking, the canonical
method involving the comparison of $$ with $(exec sh -c 'echo $PPID')
doesn't work either, as subshells don't get separate PIDs.

As far as I can tell, that leaves ksh93 without *any* reliable way of
figuring out if you're in a subshell.

I need this capability for my shell library to support ksh93. If anyone
can think of any workarounds, please let me know.

Many thanks,

- Martijn
_______________________________________________
ast-developers mailing list
ast-developers@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to